super-three 0.135.0 → 0.136.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 (175) hide show
  1. package/build/three.js +527 -332
  2. package/build/three.min.js +1 -1
  3. package/build/three.module.js +752 -370
  4. package/examples/fonts/tabler-icons/fonts/tabler-icons.svg +3966 -0
  5. package/examples/js/animation/CCDIKSolver.js +0 -1
  6. package/examples/js/animation/MMDPhysics.js +1 -3
  7. package/examples/js/controls/ArcballControls.js +38 -52
  8. package/examples/js/controls/TransformControls.js +24 -1
  9. package/examples/js/curves/CurveExtras.js +0 -2
  10. package/examples/js/effects/AsciiEffect.js +2 -9
  11. package/examples/js/exporters/GLTFExporter.js +1 -1
  12. package/examples/js/geometries/TeapotGeometry.js +0 -1
  13. package/examples/js/interactive/SelectionBox.js +2 -0
  14. package/examples/js/interactive/SelectionHelper.js +22 -7
  15. package/examples/js/lights/RectAreaLightUniformsLib.js +4 -0
  16. package/examples/js/loaders/AMFLoader.js +0 -2
  17. package/examples/js/loaders/ColladaLoader.js +1 -2
  18. package/examples/js/loaders/EXRLoader.js +185 -262
  19. package/examples/js/loaders/FBXLoader.js +3 -4
  20. package/examples/js/loaders/GLTFLoader.js +2 -2
  21. package/examples/js/loaders/HDRCubeTextureLoader.js +0 -8
  22. package/examples/js/loaders/KTX2Loader.js +11 -2
  23. package/examples/js/loaders/KTXLoader.js +1 -1
  24. package/examples/js/loaders/LDrawLoader.js +26 -30
  25. package/examples/js/loaders/LUT3dlLoader.js +2 -0
  26. package/examples/js/loaders/LUTCubeLoader.js +2 -0
  27. package/examples/js/loaders/MMDLoader.js +0 -1
  28. package/examples/js/loaders/NRRDLoader.js +9 -2
  29. package/examples/js/loaders/OBJLoader.js +0 -2
  30. package/examples/js/loaders/PLYLoader.js +1 -1
  31. package/examples/js/loaders/RGBELoader.js +0 -15
  32. package/examples/js/loaders/RGBMLoader.js +55 -5
  33. package/examples/js/loaders/SVGLoader.js +2 -2
  34. package/examples/js/loaders/VOXLoader.js +1 -0
  35. package/examples/js/loaders/VRMLLoader.js +2 -1
  36. package/examples/js/math/ImprovedNoise.js +1 -1
  37. package/examples/js/misc/GPUComputationRenderer.js +3 -1
  38. package/examples/js/objects/Lensflare.js +2 -10
  39. package/examples/js/objects/Reflector.js +7 -0
  40. package/examples/js/objects/Refractor.js +7 -0
  41. package/examples/js/objects/Sky.js +1 -1
  42. package/examples/js/objects/Water.js +2 -2
  43. package/examples/js/objects/Water2.js +4 -7
  44. package/examples/js/postprocessing/GlitchPass.js +3 -1
  45. package/examples/js/postprocessing/SSAOPass.js +1 -0
  46. package/examples/js/shaders/ConvolutionShader.js +0 -1
  47. package/examples/js/shaders/FXAAShader.js +1 -1
  48. package/examples/js/shaders/FilmShader.js +1 -1
  49. package/examples/js/shaders/GammaCorrectionShader.js +1 -1
  50. package/examples/js/shaders/HorizontalBlurShader.js +1 -2
  51. package/examples/js/shaders/SSRShader.js +1 -1
  52. package/examples/js/shaders/SSRrShader.js +1 -1
  53. package/examples/js/shaders/VerticalBlurShader.js +1 -2
  54. package/examples/js/utils/GeometryUtils.js +1 -1
  55. package/examples/js/utils/RoughnessMipmapper.js +18 -29
  56. package/examples/jsm/animation/CCDIKSolver.js +0 -1
  57. package/examples/jsm/animation/MMDPhysics.js +0 -2
  58. package/examples/jsm/controls/ArcballControls.js +27 -56
  59. package/examples/jsm/controls/TransformControls.js +24 -1
  60. package/examples/jsm/curves/CurveExtras.js +0 -2
  61. package/examples/jsm/effects/AsciiEffect.js +2 -9
  62. package/examples/jsm/exporters/GLTFExporter.js +1 -1
  63. package/examples/jsm/geometries/TeapotGeometry.js +0 -1
  64. package/examples/jsm/interactive/SelectionBox.js +1 -0
  65. package/examples/jsm/interactive/SelectionHelper.js +19 -7
  66. package/examples/jsm/libs/flow.module.js +256 -136
  67. package/examples/jsm/lights/RectAreaLightUniformsLib.js +7 -0
  68. package/examples/jsm/loaders/AMFLoader.js +0 -2
  69. package/examples/jsm/loaders/ColladaLoader.js +1 -2
  70. package/examples/jsm/loaders/EXRLoader.js +184 -293
  71. package/examples/jsm/loaders/FBXLoader.js +3 -4
  72. package/examples/jsm/loaders/GLTFLoader.js +2 -2
  73. package/examples/jsm/loaders/HDRCubeTextureLoader.js +1 -14
  74. package/examples/jsm/loaders/KTX2Loader.js +13 -4
  75. package/examples/jsm/loaders/KTXLoader.js +1 -1
  76. package/examples/jsm/loaders/LDrawLoader.js +23 -24
  77. package/examples/jsm/loaders/LUT3dlLoader.js +2 -0
  78. package/examples/jsm/loaders/LUTCubeLoader.js +2 -0
  79. package/examples/jsm/loaders/MMDLoader.js +0 -1
  80. package/examples/jsm/loaders/NRRDLoader.js +10 -2
  81. package/examples/jsm/loaders/OBJLoader.js +0 -2
  82. package/examples/jsm/loaders/PLYLoader.js +1 -1
  83. package/examples/jsm/loaders/RGBELoader.js +0 -20
  84. package/examples/jsm/loaders/RGBMLoader.js +61 -7
  85. package/examples/jsm/loaders/SVGLoader.js +2 -2
  86. package/examples/jsm/loaders/TDSLoader.js +30 -9
  87. package/examples/jsm/loaders/VOXLoader.js +1 -0
  88. package/examples/jsm/loaders/VRMLLoader.js +2 -1
  89. package/examples/jsm/math/ImprovedNoise.js +1 -1
  90. package/examples/jsm/misc/GPUComputationRenderer.js +3 -1
  91. package/examples/jsm/node-editor/NodeEditor.js +23 -22
  92. package/examples/jsm/node-editor/examples/rim.json +1 -1
  93. package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +48 -9
  94. package/examples/jsm/node-editor/utils/OscillatorEditor.js +1 -1
  95. package/examples/jsm/nodes/core/NodeBuilder.js +2 -2
  96. package/examples/jsm/nodes/materials/nodes/StandardNode.js +1 -0
  97. package/examples/jsm/nodes/math/MathNode.js +12 -0
  98. package/examples/jsm/nodes/misc/BumpMapNode.js +1 -1
  99. package/examples/jsm/nodes/misc/TextureCubeUVNode.js +1 -4
  100. package/examples/jsm/nodes/utils/ColorSpaceNode.js +1 -116
  101. package/examples/jsm/objects/Lensflare.js +3 -14
  102. package/examples/jsm/objects/Reflector.js +7 -0
  103. package/examples/jsm/objects/Refractor.js +7 -0
  104. package/examples/jsm/objects/Sky.js +1 -1
  105. package/examples/jsm/objects/Water.js +2 -2
  106. package/examples/jsm/objects/Water2.js +4 -8
  107. package/examples/jsm/postprocessing/GlitchPass.js +3 -1
  108. package/examples/jsm/postprocessing/SAOPass.js +1 -1
  109. package/examples/jsm/postprocessing/SSAOPass.js +1 -0
  110. package/examples/jsm/renderers/nodes/Nodes.js +1 -0
  111. package/examples/jsm/renderers/nodes/ShaderNode.js +7 -6
  112. package/examples/jsm/renderers/nodes/core/InputNode.js +1 -1
  113. package/examples/jsm/renderers/nodes/core/NodeBuilder.js +1 -1
  114. package/examples/jsm/renderers/nodes/display/ColorSpaceNode.js +26 -31
  115. package/examples/jsm/renderers/nodes/functions/BSDFs.js +2 -2
  116. package/examples/jsm/renderers/nodes/functions/PhysicalMaterialFunctions.js +27 -0
  117. package/examples/jsm/renderers/nodes/inputs/TextureNode.js +1 -1
  118. package/examples/jsm/renderers/nodes/math/MathNode.js +5 -3
  119. package/examples/jsm/renderers/nodes/math/OperatorNode.js +2 -2
  120. package/examples/jsm/renderers/nodes/utils/TimerNode.js +1 -1
  121. package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +14 -14
  122. package/examples/jsm/renderers/webgpu/WebGPUBindings.js +7 -6
  123. package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +1 -1
  124. package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +42 -61
  125. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +2 -2
  126. package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +0 -1
  127. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +30 -4
  128. package/examples/jsm/shaders/ConvolutionShader.js +0 -1
  129. package/examples/jsm/shaders/FXAAShader.js +1 -1
  130. package/examples/jsm/shaders/FilmShader.js +1 -1
  131. package/examples/jsm/shaders/GammaCorrectionShader.js +1 -1
  132. package/examples/jsm/shaders/HorizontalBlurShader.js +1 -2
  133. package/examples/jsm/shaders/SSRShader.js +1 -1
  134. package/examples/jsm/shaders/SSRrShader.js +1 -1
  135. package/examples/jsm/shaders/VerticalBlurShader.js +1 -2
  136. package/examples/jsm/utils/GeometryUtils.js +1 -1
  137. package/examples/jsm/utils/RoughnessMipmapper.js +19 -32
  138. package/examples/jsm/utils/WorkerPool.js +11 -11
  139. package/package.json +15 -9
  140. package/src/Three.Legacy.js +12 -0
  141. package/src/Three.js +1 -2
  142. package/src/constants.js +1 -7
  143. package/src/core/Object3D.js +1 -1
  144. package/src/extras/PMREMGenerator.js +19 -110
  145. package/src/extras/core/Interpolations.js +1 -1
  146. package/src/geometries/LatheGeometry.js +70 -47
  147. package/src/helpers/CameraHelper.js +1 -1
  148. package/src/loaders/FileLoader.js +23 -6
  149. package/src/math/Color.js +0 -38
  150. package/src/math/Ray.js +2 -2
  151. package/src/math/Sphere.js +10 -1
  152. package/src/objects/Skeleton.js +1 -0
  153. package/src/renderers/WebGLRenderer.js +23 -16
  154. package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +1 -1
  155. package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +2 -24
  156. package/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js +0 -47
  157. package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +1 -1
  158. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +27 -1
  159. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +1 -1
  160. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +10 -0
  161. package/src/renderers/webgl/WebGLCapabilities.js +0 -2
  162. package/src/renderers/webgl/WebGLMorphtargets.js +1 -0
  163. package/src/renderers/webgl/WebGLProgram.js +2 -19
  164. package/src/renderers/webgl/WebGLPrograms.js +191 -35
  165. package/src/renderers/webgl/WebGLRenderLists.js +4 -14
  166. package/src/renderers/webgl/WebGLShaderCache.js +120 -0
  167. package/src/renderers/webgl/WebGLState.js +45 -0
  168. package/src/renderers/webgl/WebGLTextures.js +195 -26
  169. package/src/renderers/webxr/WebXRManager.js +10 -3
  170. package/src/scenes/Scene.js +1 -1
  171. package/src/textures/DataTexture.js +0 -2
  172. package/src/textures/DataTexture2DArray.js +0 -2
  173. package/src/textures/DataTexture3D.js +0 -2
  174. package/src/textures/FramebufferTexture.js +25 -0
  175. package/src/utils.js +1 -37
@@ -5,12 +5,8 @@ import {
5
5
  HalfFloatType,
6
6
  LinearEncoding,
7
7
  LinearFilter,
8
- NearestFilter,
9
- RGBAFormat,
10
- RGBEEncoding,
11
- RGBEFormat,
12
- RGBFormat,
13
- UnsignedByteType
8
+ RedFormat,
9
+ RGBAFormat
14
10
  } from 'three';
15
11
  import * as fflate from '../libs/fflate.module.js';
16
12
 
@@ -132,41 +128,6 @@ class EXRLoader extends DataTextureLoader {
132
128
 
133
129
  const logBase = Math.pow( 2.7182818, 2.2 );
134
130
 
135
- var tmpDataView = new DataView( new ArrayBuffer( 8 ) );
136
-
137
- function frexp( value ) {
138
-
139
- if ( value === 0 ) return [ value, 0 ];
140
-
141
- tmpDataView.setFloat64( 0, value );
142
-
143
- var bits = ( tmpDataView.getUint32( 0 ) >>> 20 ) & 0x7FF;
144
- if ( bits === 0 ) { // denormal
145
-
146
- tmpDataView.setFloat64( 0, value * Math.pow( 2, 64 ) ); // exp + 64
147
- bits = ( ( tmpDataView.getUint32( 0 ) >>> 20 ) & 0x7FF ) - 64;
148
-
149
- }
150
-
151
- var exponent = bits - 1022;
152
- var mantissa = ldexp( value, - exponent );
153
-
154
- return [ mantissa, exponent ];
155
-
156
- }
157
-
158
- function ldexp( mantissa, exponent ) {
159
-
160
- var steps = Math.min( 3, Math.ceil( Math.abs( exponent ) / 1023 ) );
161
- var result = mantissa;
162
-
163
- for ( var i = 0; i < steps; i ++ )
164
- result *= Math.pow( 2, Math.floor( ( exponent + i ) / steps ) );
165
-
166
- return result;
167
-
168
- }
169
-
170
131
  function reverseLutFromBitmap( bitmap, lut ) {
171
132
 
172
133
  var k = 0;
@@ -1312,8 +1273,7 @@ class EXRLoader extends DataTextureLoader {
1312
1273
  var inDataView = info.viewer;
1313
1274
  var inOffset = { value: info.offset.value };
1314
1275
 
1315
- var tmpBufSize = info.width * scanlineBlockSize * ( EXRHeader.channels.length * info.type );
1316
- var outBuffer = new Uint16Array( tmpBufSize );
1276
+ var outBuffer = new Uint16Array( info.width * info.scanlineBlockSize * ( info.channels * info.type ) );
1317
1277
  var bitmap = new Uint8Array( BITMAP_SIZE );
1318
1278
 
1319
1279
  // Setup channel info
@@ -1333,6 +1293,7 @@ class EXRLoader extends DataTextureLoader {
1333
1293
  }
1334
1294
 
1335
1295
  // Read range compression data
1296
+
1336
1297
  var minNonZero = parseUint16( inDataView, inOffset );
1337
1298
  var maxNonZero = parseUint16( inDataView, inOffset );
1338
1299
 
@@ -1489,7 +1450,7 @@ class EXRLoader extends DataTextureLoader {
1489
1450
 
1490
1451
  var inDataView = info.viewer;
1491
1452
  var inOffset = { value: info.offset.value };
1492
- var outBuffer = new Uint8Array( info.width * info.lines * ( EXRHeader.channels.length * info.type * INT16_SIZE ) );
1453
+ var outBuffer = new Uint8Array( info.width * info.lines * ( info.channels * info.type * INT16_SIZE ) );
1493
1454
 
1494
1455
  // Read compression header information
1495
1456
  var dwaHeader = {
@@ -1737,16 +1698,6 @@ class EXRLoader extends DataTextureLoader {
1737
1698
 
1738
1699
  }
1739
1700
 
1740
- function parseUlong( dataView, offset ) {
1741
-
1742
- var uLong = dataView.getUint32( 0, true );
1743
-
1744
- offset.value = offset.value + ULONG_SIZE;
1745
-
1746
- return uLong;
1747
-
1748
- }
1749
-
1750
1701
  function parseRational( dataView, offset ) {
1751
1702
 
1752
1703
  var x = parseInt32( dataView, offset );
@@ -2037,311 +1988,271 @@ class EXRLoader extends DataTextureLoader {
2037
1988
 
2038
1989
  }
2039
1990
 
2040
- var bufferDataView = new DataView( buffer );
2041
- var uInt8Array = new Uint8Array( buffer );
1991
+ function parseHeader( dataView, buffer, offset ) {
2042
1992
 
2043
- var EXRHeader = {};
1993
+ const EXRHeader = {};
2044
1994
 
2045
- bufferDataView.getUint32( 0, true ); // magic
2046
- bufferDataView.getUint8( 4, true ); // versionByteZero
2047
- bufferDataView.getUint8( 5, true ); // fullMask
1995
+ if ( dataView.getUint32( 0, true ) != 20000630 ) // magic
1996
+ throw 'THREE.EXRLoader: provided file doesn\'t appear to be in OpenEXR format.';
2048
1997
 
2049
- // start of header
1998
+ EXRHeader.version = dataView.getUint8( 4, true );
2050
1999
 
2051
- var offset = { value: 8 }; // start at 8, after magic stuff
2000
+ const spec = dataView.getUint8( 5, true ); // fullMask
2052
2001
 
2053
- var keepReading = true;
2054
-
2055
- while ( keepReading ) {
2002
+ EXRHeader.spec = {
2003
+ singleTile: !! ( spec & 1 ),
2004
+ longName: !! ( spec & 2 ),
2005
+ deepFormat: !! ( spec & 4 ),
2006
+ multiPart: !! ( spec & 8 ),
2007
+ };
2056
2008
 
2057
- var attributeName = parseNullTerminatedString( buffer, offset );
2009
+ // start of header
2058
2010
 
2059
- if ( attributeName == 0 ) {
2011
+ offset.value = 8; // start at 8 - after pre-amble
2060
2012
 
2061
- keepReading = false;
2013
+ var keepReading = true;
2062
2014
 
2063
- } else {
2015
+ while ( keepReading ) {
2064
2016
 
2065
- var attributeType = parseNullTerminatedString( buffer, offset );
2066
- var attributeSize = parseUint32( bufferDataView, offset );
2067
- var attributeValue = parseValue( bufferDataView, buffer, offset, attributeType, attributeSize );
2017
+ var attributeName = parseNullTerminatedString( buffer, offset );
2068
2018
 
2069
- if ( attributeValue === undefined ) {
2019
+ if ( attributeName == 0 ) {
2070
2020
 
2071
- console.warn( `EXRLoader.parse: skipped unknown header attribute type \'${ attributeType }\'.` );
2021
+ keepReading = false;
2072
2022
 
2073
2023
  } else {
2074
2024
 
2075
- EXRHeader[ attributeName ] = attributeValue;
2025
+ var attributeType = parseNullTerminatedString( buffer, offset );
2026
+ var attributeSize = parseUint32( dataView, offset );
2027
+ var attributeValue = parseValue( dataView, buffer, offset, attributeType, attributeSize );
2076
2028
 
2077
- }
2078
-
2079
- }
2080
-
2081
- }
2082
-
2083
- // offsets
2084
- var dataWindowHeight = EXRHeader.dataWindow.yMax + 1;
2085
-
2086
- var uncompress;
2087
- var scanlineBlockSize;
2088
-
2089
- switch ( EXRHeader.compression ) {
2090
-
2091
- case 'NO_COMPRESSION':
2092
-
2093
- scanlineBlockSize = 1;
2094
- uncompress = uncompressRAW;
2095
- break;
2096
-
2097
- case 'RLE_COMPRESSION':
2098
-
2099
- scanlineBlockSize = 1;
2100
- uncompress = uncompressRLE;
2101
- break;
2102
-
2103
- case 'ZIPS_COMPRESSION':
2104
-
2105
- scanlineBlockSize = 1;
2106
- uncompress = uncompressZIP;
2107
- break;
2029
+ if ( attributeValue === undefined ) {
2108
2030
 
2109
- case 'ZIP_COMPRESSION':
2031
+ console.warn( `EXRLoader.parse: skipped unknown header attribute type \'${attributeType}\'.` );
2110
2032
 
2111
- scanlineBlockSize = 16;
2112
- uncompress = uncompressZIP;
2113
- break;
2114
-
2115
- case 'PIZ_COMPRESSION':
2116
-
2117
- scanlineBlockSize = 32;
2118
- uncompress = uncompressPIZ;
2119
- break;
2033
+ } else {
2120
2034
 
2121
- case 'PXR24_COMPRESSION':
2035
+ EXRHeader[ attributeName ] = attributeValue;
2122
2036
 
2123
- scanlineBlockSize = 16;
2124
- uncompress = uncompressPXR;
2125
- break;
2037
+ }
2126
2038
 
2127
- case 'DWAA_COMPRESSION':
2039
+ }
2128
2040
 
2129
- scanlineBlockSize = 32;
2130
- uncompress = uncompressDWA;
2131
- break;
2041
+ }
2132
2042
 
2133
- case 'DWAB_COMPRESSION':
2043
+ if ( spec != 0 ) {
2134
2044
 
2135
- scanlineBlockSize = 256;
2136
- uncompress = uncompressDWA;
2137
- break;
2045
+ console.error( 'EXRHeader:', EXRHeader );
2046
+ throw 'THREE.EXRLoader: provided file is currently unsupported.';
2138
2047
 
2139
- default:
2048
+ }
2140
2049
 
2141
- throw 'EXRLoader.parse: ' + EXRHeader.compression + ' is unsupported';
2050
+ return EXRHeader;
2142
2051
 
2143
2052
  }
2144
2053
 
2145
- var size_t;
2146
- var getValue;
2054
+ function setupDecoder( EXRHeader, dataView, uInt8Array, offset, outputType ) {
2147
2055
 
2148
- // mixed pixelType not supported
2149
- var pixelType = EXRHeader.channels[ 0 ].pixelType;
2150
-
2151
- if ( pixelType === 1 ) { // half
2152
-
2153
- switch ( this.type ) {
2056
+ const EXRDecoder = {
2057
+ size: 0,
2058
+ viewer: dataView,
2059
+ array: uInt8Array,
2060
+ offset: offset,
2061
+ width: EXRHeader.dataWindow.xMax - EXRHeader.dataWindow.xMin + 1,
2062
+ height: EXRHeader.dataWindow.yMax - EXRHeader.dataWindow.yMin + 1,
2063
+ channels: EXRHeader.channels.length,
2064
+ bytesPerLine: null,
2065
+ lines: null,
2066
+ inputSize: null,
2067
+ type: EXRHeader.channels[ 0 ].pixelType,
2068
+ uncompress: null,
2069
+ getter: null,
2070
+ format: null,
2071
+ encoding: null,
2072
+ };
2154
2073
 
2155
- case UnsignedByteType:
2156
- case FloatType:
2074
+ switch ( EXRHeader.compression ) {
2157
2075
 
2158
- getValue = parseFloat16;
2159
- size_t = INT16_SIZE;
2076
+ case 'NO_COMPRESSION':
2077
+ EXRDecoder.lines = 1;
2078
+ EXRDecoder.uncompress = uncompressRAW;
2160
2079
  break;
2161
2080
 
2162
- case HalfFloatType:
2163
-
2164
- getValue = parseUint16;
2165
- size_t = INT16_SIZE;
2081
+ case 'RLE_COMPRESSION':
2082
+ EXRDecoder.lines = 1;
2083
+ EXRDecoder.uncompress = uncompressRLE;
2166
2084
  break;
2167
2085
 
2168
- }
2086
+ case 'ZIPS_COMPRESSION':
2087
+ EXRDecoder.lines = 1;
2088
+ EXRDecoder.uncompress = uncompressZIP;
2089
+ break;
2169
2090
 
2170
- } else if ( pixelType === 2 ) { // float
2091
+ case 'ZIP_COMPRESSION':
2092
+ EXRDecoder.lines = 16;
2093
+ EXRDecoder.uncompress = uncompressZIP;
2094
+ break;
2171
2095
 
2172
- switch ( this.type ) {
2096
+ case 'PIZ_COMPRESSION':
2097
+ EXRDecoder.lines = 32;
2098
+ EXRDecoder.uncompress = uncompressPIZ;
2099
+ break;
2173
2100
 
2174
- case UnsignedByteType:
2175
- case FloatType:
2101
+ case 'PXR24_COMPRESSION':
2102
+ EXRDecoder.lines = 16;
2103
+ EXRDecoder.uncompress = uncompressPXR;
2104
+ break;
2176
2105
 
2177
- getValue = parseFloat32;
2178
- size_t = FLOAT32_SIZE;
2106
+ case 'DWAA_COMPRESSION':
2107
+ EXRDecoder.lines = 32;
2108
+ EXRDecoder.uncompress = uncompressDWA;
2179
2109
  break;
2180
2110
 
2181
- case HalfFloatType:
2111
+ case 'DWAB_COMPRESSION':
2112
+ EXRDecoder.lines = 256;
2113
+ EXRDecoder.uncompress = uncompressDWA;
2114
+ break;
2182
2115
 
2183
- getValue = decodeFloat32;
2184
- size_t = FLOAT32_SIZE;
2116
+ default:
2117
+ throw 'EXRLoader.parse: ' + EXRHeader.compression + ' is unsupported';
2185
2118
 
2186
2119
  }
2187
2120
 
2188
- } else {
2189
-
2190
- throw 'EXRLoader.parse: unsupported pixelType ' + pixelType + ' for ' + EXRHeader.compression + '.';
2191
-
2192
- }
2193
-
2194
- var numBlocks = dataWindowHeight / scanlineBlockSize;
2195
-
2196
- for ( var i = 0; i < numBlocks; i ++ ) {
2197
-
2198
- parseUlong( bufferDataView, offset ); // scanlineOffset
2199
-
2200
- }
2201
-
2202
- // we should be passed the scanline offset table, start reading pixel data
2203
-
2204
- var width = EXRHeader.dataWindow.xMax - EXRHeader.dataWindow.xMin + 1;
2205
- var height = EXRHeader.dataWindow.yMax - EXRHeader.dataWindow.yMin + 1;
2206
- // Firefox only supports RGBA (half) float textures
2207
- // var numChannels = EXRHeader.channels.length;
2208
- var numChannels = 4;
2209
- var size = width * height * numChannels;
2210
-
2211
- // Fill initially with 1s for the alpha value if the texture is not RGBA, RGB values will be overwritten
2212
- switch ( this.type ) {
2121
+ EXRDecoder.scanlineBlockSize = EXRDecoder.lines;
2213
2122
 
2214
- case UnsignedByteType:
2215
- case FloatType:
2123
+ if ( EXRDecoder.type == 1 ) {
2216
2124
 
2217
- var byteArray = new Float32Array( size );
2125
+ // half
2126
+ switch ( outputType ) {
2218
2127
 
2219
- if ( EXRHeader.channels.length < numChannels ) {
2128
+ case FloatType:
2129
+ EXRDecoder.getter = parseFloat16;
2130
+ EXRDecoder.inputSize = INT16_SIZE;
2131
+ break;
2220
2132
 
2221
- byteArray.fill( 1, 0, size );
2133
+ case HalfFloatType:
2134
+ EXRDecoder.getter = parseUint16;
2135
+ EXRDecoder.inputSize = INT16_SIZE;
2136
+ break;
2222
2137
 
2223
2138
  }
2224
2139
 
2225
- break;
2226
-
2227
- case HalfFloatType:
2140
+ } else if ( EXRDecoder.type == 2 ) {
2228
2141
 
2229
- var byteArray = new Uint16Array( size );
2142
+ // float
2143
+ switch ( outputType ) {
2230
2144
 
2231
- if ( EXRHeader.channels.length < numChannels ) {
2145
+ case FloatType:
2146
+ EXRDecoder.getter = parseFloat32;
2147
+ EXRDecoder.inputSize = FLOAT32_SIZE;
2148
+ break;
2232
2149
 
2233
- byteArray.fill( 0x3C00, 0, size ); // Uint16Array holds half float data, 0x3C00 is 1
2150
+ case HalfFloatType:
2151
+ EXRDecoder.getter = decodeFloat32;
2152
+ EXRDecoder.inputSize = FLOAT32_SIZE;
2234
2153
 
2235
2154
  }
2236
2155
 
2237
- break;
2238
-
2239
- default:
2156
+ } else {
2240
2157
 
2241
- console.error( 'THREE.EXRLoader: unsupported type: ', this.type );
2242
- break;
2158
+ throw 'EXRLoader.parse: unsupported pixelType ' + EXRDecoder.type + ' for ' + EXRHeader.compression + '.';
2243
2159
 
2244
- }
2160
+ }
2245
2161
 
2246
- var channelOffsets = {
2247
- R: 0,
2248
- G: 1,
2249
- B: 2,
2250
- A: 3
2251
- };
2162
+ EXRDecoder.blockCount = ( EXRHeader.dataWindow.yMax + 1 ) / EXRDecoder.scanlineBlockSize;
2252
2163
 
2253
- var compressionInfo = {
2164
+ for ( var i = 0; i < EXRDecoder.blockCount; i ++ )
2165
+ parseInt64( dataView, offset ); // scanlineOffset
2254
2166
 
2255
- size: 0,
2256
- width: width,
2257
- lines: scanlineBlockSize,
2167
+ // we should be passed the scanline offset table, ready to start reading pixel data.
2258
2168
 
2259
- offset: offset,
2260
- array: uInt8Array,
2261
- viewer: bufferDataView,
2169
+ // RGB images will be converted to RGBA format, preventing software emulation in select devices.
2170
+ EXRDecoder.outputChannels = ( ( EXRDecoder.channels == 3 ) ? 4 : EXRDecoder.channels );
2171
+ const size = EXRDecoder.width * EXRDecoder.height * EXRDecoder.outputChannels;
2262
2172
 
2263
- type: pixelType,
2264
- channels: EXRHeader.channels.length,
2173
+ switch ( outputType ) {
2265
2174
 
2266
- };
2175
+ case FloatType:
2176
+ EXRDecoder.byteArray = new Float32Array( size );
2267
2177
 
2268
- var line;
2269
- var size;
2270
- var viewer;
2271
- var tmpOffset = { value: 0 };
2178
+ // Fill initially with 1s for the alpha value if the texture is not RGBA, RGB values will be overwritten
2179
+ if ( EXRDecoder.channels < EXRDecoder.outputChannels )
2180
+ EXRDecoder.byteArray.fill( 1, 0, size );
2272
2181
 
2273
- for ( var scanlineBlockIdx = 0; scanlineBlockIdx < height / scanlineBlockSize; scanlineBlockIdx ++ ) {
2182
+ break;
2274
2183
 
2275
- line = parseUint32( bufferDataView, offset ); // line_no
2276
- size = parseUint32( bufferDataView, offset ); // data_len
2184
+ case HalfFloatType:
2185
+ EXRDecoder.byteArray = new Uint16Array( size );
2277
2186
 
2278
- compressionInfo.lines = ( line + scanlineBlockSize > height ) ? height - line : scanlineBlockSize;
2279
- compressionInfo.offset = offset;
2280
- compressionInfo.size = size;
2187
+ if ( EXRDecoder.channels < EXRDecoder.outputChannels )
2188
+ EXRDecoder.byteArray.fill( 0x3C00, 0, size ); // Uint16Array holds half float data, 0x3C00 is 1
2281
2189
 
2282
- viewer = uncompress( compressionInfo );
2190
+ break;
2283
2191
 
2284
- offset.value += size;
2192
+ default:
2193
+ console.error( 'THREE.EXRLoader: unsupported type: ', outputType );
2194
+ break;
2285
2195
 
2286
- for ( var line_y = 0; line_y < scanlineBlockSize; line_y ++ ) {
2196
+ }
2287
2197
 
2288
- var true_y = line_y + ( scanlineBlockIdx * scanlineBlockSize );
2198
+ EXRDecoder.bytesPerLine = EXRDecoder.width * EXRDecoder.inputSize * EXRDecoder.channels;
2289
2199
 
2290
- if ( true_y >= height ) break;
2200
+ if ( EXRDecoder.outputChannels == 4 ) {
2291
2201
 
2292
- for ( var channelID = 0; channelID < EXRHeader.channels.length; channelID ++ ) {
2202
+ EXRDecoder.format = RGBAFormat;
2203
+ EXRDecoder.encoding = LinearEncoding;
2293
2204
 
2294
- var cOff = channelOffsets[ EXRHeader.channels[ channelID ].name ];
2205
+ } else {
2295
2206
 
2296
- for ( var x = 0; x < width; x ++ ) {
2207
+ EXRDecoder.format = RedFormat;
2208
+ EXRDecoder.encoding = LinearEncoding;
2297
2209
 
2298
- var idx = ( line_y * ( EXRHeader.channels.length * width ) ) + ( channelID * width ) + x;
2299
- tmpOffset.value = idx * size_t;
2210
+ }
2300
2211
 
2301
- var val = getValue( viewer, tmpOffset );
2212
+ return EXRDecoder;
2302
2213
 
2303
- byteArray[ ( ( ( height - 1 - true_y ) * ( width * numChannels ) ) + ( x * numChannels ) ) + cOff ] = val;
2214
+ }
2304
2215
 
2305
- }
2216
+ // start parsing file [START]
2306
2217
 
2307
- }
2218
+ const bufferDataView = new DataView( buffer );
2219
+ const uInt8Array = new Uint8Array( buffer );
2220
+ const offset = { value: 0 };
2308
2221
 
2309
- }
2222
+ // get header information and validate format.
2223
+ const EXRHeader = parseHeader( bufferDataView, buffer, offset );
2310
2224
 
2311
- }
2225
+ // get input compression information and prepare decoding.
2226
+ const EXRDecoder = setupDecoder( EXRHeader, bufferDataView, uInt8Array, offset, this.type );
2312
2227
 
2313
- if ( this.type === UnsignedByteType ) {
2228
+ const tmpOffset = { value: 0 };
2229
+ const channelOffsets = { R: 0, G: 1, B: 2, A: 3, Y: 0 };
2314
2230
 
2315
- let v, i;
2316
- const size = byteArray.length;
2317
- const RGBEArray = new Uint8Array( size );
2231
+ for ( let scanlineBlockIdx = 0; scanlineBlockIdx < EXRDecoder.height / EXRDecoder.scanlineBlockSize; scanlineBlockIdx ++ ) {
2318
2232
 
2319
- for ( let h = 0; h < height; ++ h ) {
2233
+ const line = parseUint32( bufferDataView, offset ); // line_no
2234
+ EXRDecoder.size = parseUint32( bufferDataView, offset ); // data_len
2235
+ EXRDecoder.lines = ( ( line + EXRDecoder.scanlineBlockSize > EXRDecoder.height ) ? ( EXRDecoder.height - line ) : EXRDecoder.scanlineBlockSize );
2320
2236
 
2321
- for ( let w = 0; w < width; ++ w ) {
2237
+ const isCompressed = EXRDecoder.size < EXRDecoder.lines * EXRDecoder.bytesPerLine;
2238
+ const viewer = isCompressed ? EXRDecoder.uncompress( EXRDecoder ) : uncompressRAW( EXRDecoder );
2322
2239
 
2323
- i = h * width * 4 + w * 4;
2240
+ offset.value += EXRDecoder.size;
2324
2241
 
2325
- const red = byteArray[ i ];
2326
- const green = byteArray[ i + 1 ];
2327
- const blue = byteArray[ i + 2 ];
2242
+ for ( let line_y = 0; line_y < EXRDecoder.scanlineBlockSize; line_y ++ ) {
2328
2243
 
2329
- v = ( red > green ) ? red : green;
2330
- v = ( blue > v ) ? blue : v;
2244
+ const true_y = line_y + scanlineBlockIdx * EXRDecoder.scanlineBlockSize;
2245
+ if ( true_y >= EXRDecoder.height ) break;
2331
2246
 
2332
- if ( v < 1e-32 ) {
2247
+ for ( let channelID = 0; channelID < EXRDecoder.channels; channelID ++ ) {
2333
2248
 
2334
- RGBEArray[ i ] = RGBEArray[ i + 1 ] = RGBEArray[ i + 2 ] = RGBEArray[ i + 3 ] = 0;
2249
+ const cOff = channelOffsets[ EXRHeader.channels[ channelID ].name ];
2335
2250
 
2336
- } else {
2251
+ for ( let x = 0; x < EXRDecoder.width; x ++ ) {
2337
2252
 
2338
- const res = frexp( v );
2339
- v = res[ 0 ] * 256 / v;
2340
-
2341
- RGBEArray[ i ] = red * v;
2342
- RGBEArray[ i + 1 ] = green * v;
2343
- RGBEArray[ i + 2 ] = blue * v;
2344
- RGBEArray[ i + 3 ] = res[ 1 ] + 128;
2253
+ tmpOffset.value = ( line_y * ( EXRDecoder.channels * EXRDecoder.width ) + channelID * EXRDecoder.width + x ) * EXRDecoder.inputSize;
2254
+ const outIndex = ( EXRDecoder.height - 1 - true_y ) * ( EXRDecoder.width * EXRDecoder.outputChannels ) + x * EXRDecoder.outputChannels + cOff;
2255
+ EXRDecoder.byteArray[ outIndex ] = EXRDecoder.getter( viewer, tmpOffset );
2345
2256
 
2346
2257
  }
2347
2258
 
@@ -2349,19 +2260,16 @@ class EXRLoader extends DataTextureLoader {
2349
2260
 
2350
2261
  }
2351
2262
 
2352
- byteArray = RGBEArray;
2353
-
2354
2263
  }
2355
2264
 
2356
- const format = ( this.type === UnsignedByteType ) ? RGBEFormat : ( numChannels === 4 ) ? RGBAFormat : RGBFormat;
2357
-
2358
2265
  return {
2359
2266
  header: EXRHeader,
2360
- width: width,
2361
- height: height,
2362
- data: byteArray,
2363
- format: format,
2364
- type: this.type
2267
+ width: EXRDecoder.width,
2268
+ height: EXRDecoder.height,
2269
+ data: EXRDecoder.byteArray,
2270
+ format: EXRDecoder.format,
2271
+ encoding: EXRDecoder.encoding,
2272
+ type: this.type,
2365
2273
  };
2366
2274
 
2367
2275
  }
@@ -2377,28 +2285,11 @@ class EXRLoader extends DataTextureLoader {
2377
2285
 
2378
2286
  function onLoadCallback( texture, texData ) {
2379
2287
 
2380
- switch ( texture.type ) {
2381
-
2382
- case UnsignedByteType:
2383
-
2384
- texture.encoding = RGBEEncoding;
2385
- texture.minFilter = NearestFilter;
2386
- texture.magFilter = NearestFilter;
2387
- texture.generateMipmaps = false;
2388
- texture.flipY = false;
2389
- break;
2390
-
2391
- case FloatType:
2392
- case HalfFloatType:
2393
-
2394
- texture.encoding = LinearEncoding;
2395
- texture.minFilter = LinearFilter;
2396
- texture.magFilter = LinearFilter;
2397
- texture.generateMipmaps = false;
2398
- texture.flipY = false;
2399
- break;
2400
-
2401
- }
2288
+ texture.encoding = texData.encoding;
2289
+ texture.minFilter = LinearFilter;
2290
+ texture.magFilter = LinearFilter;
2291
+ texture.generateMipmaps = false;
2292
+ texture.flipY = false;
2402
2293
 
2403
2294
  if ( onLoad ) onLoad( texture, texData );
2404
2295
 
@@ -53,11 +53,10 @@ import { NURBSCurve } from '../curves/NURBSCurve.js';
53
53
  * Morph normals / blend shape normals
54
54
  *
55
55
  * FBX format references:
56
- * https://wiki.blender.org/index.php/User:Mont29/Foundation/FBX_File_Structure
57
- * http://help.autodesk.com/view/FBX/2017/ENU/?guid=__cpp_ref_index_html (C++ SDK reference)
56
+ * https://help.autodesk.com/view/FBX/2017/ENU/?guid=__cpp_ref_index_html (C++ SDK reference)
58
57
  *
59
- * Binary format specification:
60
- * https://code.blender.org/2013/08/fbx-binary-file-format-specification/
58
+ * Binary format specification:
59
+ * https://code.blender.org/2013/08/fbx-binary-file-format-specification/
61
60
  */
62
61
 
63
62
 
@@ -1445,7 +1445,7 @@ class GLTFTextureTransformExtension {
1445
1445
  /**
1446
1446
  * Specular-Glossiness Extension
1447
1447
  *
1448
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness
1448
+ * Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Archived/KHR_materials_pbrSpecularGlossiness
1449
1449
  */
1450
1450
 
1451
1451
  /**
@@ -2253,7 +2253,7 @@ class GLTFParser {
2253
2253
 
2254
2254
  // Use an ImageBitmapLoader if imageBitmaps are supported. Moves much of the
2255
2255
  // expensive work of uploading a texture to the GPU off the main thread.
2256
- if ( typeof createImageBitmap !== 'undefined' && /Firefox/.test( navigator.userAgent ) === false ) {
2256
+ if ( typeof createImageBitmap !== 'undefined' && /Firefox|Safari/.test( navigator.userAgent ) === false ) {
2257
2257
 
2258
2258
  this.textureLoader = new ImageBitmapLoader( this.options.manager );
2259
2259