three-stdlib 2.6.0 → 2.6.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. package/{Nodes-acab3ca5.js → Nodes-427f68b0.js} +0 -0
  2. package/{Nodes-244507d0.js → Nodes-ec4e1143.js} +0 -0
  3. package/controls/TrackballControls.cjs.js +1 -1
  4. package/controls/TrackballControls.js +19 -6
  5. package/index.cjs.js +1 -1
  6. package/index.js +1 -1
  7. package/loaders/AMFLoader.js +1 -3
  8. package/loaders/ColladaLoader.cjs.js +1 -1
  9. package/loaders/ColladaLoader.js +58 -35
  10. package/loaders/EXRLoader.cjs.js +1 -1
  11. package/loaders/EXRLoader.js +197 -262
  12. package/loaders/FBXLoader.cjs.js +1 -1
  13. package/loaders/FBXLoader.js +41 -90
  14. package/loaders/GLTFLoader.cjs.js +1 -1
  15. package/loaders/GLTFLoader.js +160 -72
  16. package/loaders/HDRCubeTextureLoader.cjs.js +1 -1
  17. package/loaders/HDRCubeTextureLoader.js +2 -10
  18. package/loaders/NodeMaterialLoader.cjs.js +1 -1
  19. package/loaders/RGBELoader.cjs.js +1 -1
  20. package/loaders/RGBELoader.js +11 -25
  21. package/loaders/RGBMLoader.cjs.js +1 -1
  22. package/loaders/RGBMLoader.js +225 -263
  23. package/loaders/SVGLoader.cjs.js +1 -1
  24. package/loaders/SVGLoader.js +46 -30
  25. package/loaders/VRMLLoader.cjs.js +1 -1
  26. package/loaders/VRMLLoader.js +2 -1
  27. package/misc/WebGL.cjs.js +1 -1
  28. package/misc/WebGL.d.ts +5 -7
  29. package/misc/WebGL.js +67 -54
  30. package/nodes/core/NodeBuilder.cjs.js +1 -1
  31. package/nodes/core/NodeBuilder.js +2 -2
  32. package/nodes/inputs/CubeTextureNode.cjs.js +1 -1
  33. package/nodes/inputs/RTTNode.cjs.js +1 -1
  34. package/nodes/inputs/ReflectorNode.cjs.js +1 -1
  35. package/nodes/inputs/ScreenNode.cjs.js +1 -1
  36. package/nodes/inputs/TextureNode.cjs.js +1 -1
  37. package/nodes/materials/BasicNodeMaterial.cjs.js +1 -1
  38. package/nodes/materials/NodeMaterial.cjs.js +1 -1
  39. package/nodes/materials/SpriteNodeMaterial.cjs.js +1 -1
  40. package/nodes/postprocessing/NodePass.cjs.js +1 -1
  41. package/nodes/postprocessing/NodePostProcessing.cjs.js +1 -1
  42. package/nodes/utils/ColorSpaceNode.cjs.js +1 -1
  43. package/nodes/utils/ColorSpaceNode.js +2 -45
  44. package/package.json +1 -1
  45. package/shaders/GammaCorrectionShader.js +1 -2
@@ -1,4 +1,4 @@
1
- import { DataTextureLoader, FloatType, HalfFloatType, UnsignedByteType, RGBEFormat, RGBAFormat, LinearEncoding, LinearFilter, RGBEEncoding, NearestFilter, DataUtils } from 'three';
1
+ import { DataTextureLoader, HalfFloatType, FloatType, RGBAFormat, LinearEncoding, RedFormat, LinearFilter, DataUtils } from 'three';
2
2
  import { unzlibSync } from 'fflate';
3
3
 
4
4
  /**
@@ -71,7 +71,7 @@ import { unzlibSync } from 'fflate';
71
71
  class EXRLoader extends DataTextureLoader {
72
72
  constructor(manager) {
73
73
  super(manager);
74
- this.type = FloatType;
74
+ this.type = HalfFloatType;
75
75
  }
76
76
 
77
77
  parse(buffer) {
@@ -103,33 +103,6 @@ class EXRLoader extends DataTextureLoader {
103
103
  const LOSSY_DCT = 1;
104
104
  const RLE = 2;
105
105
  const logBase = Math.pow(2.7182818, 2.2);
106
- var tmpDataView = new DataView(new ArrayBuffer(8));
107
-
108
- function frexp(value) {
109
- if (value === 0) return [value, 0];
110
- tmpDataView.setFloat64(0, value);
111
- var bits = tmpDataView.getUint32(0) >>> 20 & 0x7ff;
112
-
113
- if (bits === 0) {
114
- // denormal
115
- tmpDataView.setFloat64(0, value * Math.pow(2, 64)); // exp + 64
116
-
117
- bits = (tmpDataView.getUint32(0) >>> 20 & 0x7ff) - 64;
118
- }
119
-
120
- var exponent = bits - 1022;
121
- var mantissa = ldexp(value, -exponent);
122
- return [mantissa, exponent];
123
- }
124
-
125
- function ldexp(mantissa, exponent) {
126
- var steps = Math.min(3, Math.ceil(Math.abs(exponent) / 1023));
127
- var result = mantissa;
128
-
129
- for (var i = 0; i < steps; i++) result *= Math.pow(2, Math.floor((exponent + i) / steps));
130
-
131
- return result;
132
- }
133
106
 
134
107
  function reverseLutFromBitmap(bitmap, lut) {
135
108
  var k = 0;
@@ -959,8 +932,7 @@ class EXRLoader extends DataTextureLoader {
959
932
  var inOffset = {
960
933
  value: info.offset.value
961
934
  };
962
- var tmpBufSize = info.width * scanlineBlockSize * (EXRHeader.channels.length * info.type);
963
- var outBuffer = new Uint16Array(tmpBufSize);
935
+ var outBuffer = new Uint16Array(info.width * info.scanlineBlockSize * (info.channels * info.type));
964
936
  var bitmap = new Uint8Array(BITMAP_SIZE); // Setup channel info
965
937
 
966
938
  var outBufferEnd = 0;
@@ -1080,7 +1052,7 @@ class EXRLoader extends DataTextureLoader {
1080
1052
  var inOffset = {
1081
1053
  value: info.offset.value
1082
1054
  };
1083
- var outBuffer = new Uint8Array(info.width * info.lines * (EXRHeader.channels.length * info.type * INT16_SIZE)); // Read compression header information
1055
+ var outBuffer = new Uint8Array(info.width * info.lines * (info.channels * info.type * INT16_SIZE)); // Read compression header information
1084
1056
 
1085
1057
  var dwaHeader = {
1086
1058
  version: parseInt64(inDataView, inOffset),
@@ -1095,11 +1067,7 @@ class EXRLoader extends DataTextureLoader {
1095
1067
  totalDcUncompressedCount: parseInt64(inDataView, inOffset),
1096
1068
  acCompression: parseInt64(inDataView, inOffset)
1097
1069
  };
1098
-
1099
- if (dwaHeader.version < 2) {
1100
- throw 'EXRLoader.parse: ' + EXRHeader.compression + ' version ' + dwaHeader.version + ' is unsupported';
1101
- } // Read channel ruleset information
1102
-
1070
+ if (dwaHeader.version < 2) throw 'EXRLoader.parse: ' + EXRHeader.compression + ' version ' + dwaHeader.version + ' is unsupported'; // Read channel ruleset information
1103
1071
 
1104
1072
  var channelRules = new Array();
1105
1073
  var ruleSize = parseUint16(inDataView, inOffset) - INT16_SIZE;
@@ -1268,12 +1236,6 @@ class EXRLoader extends DataTextureLoader {
1268
1236
  return stringValue;
1269
1237
  }
1270
1238
 
1271
- function parseUlong(dataView, offset) {
1272
- var uLong = dataView.getUint32(0, true);
1273
- offset.value = offset.value + ULONG_SIZE;
1274
- return uLong;
1275
- }
1276
-
1277
1239
  function parseRational(dataView, offset) {
1278
1240
  var x = parseInt32(dataView, offset);
1279
1241
  var y = parseUint32(dataView, offset);
@@ -1461,253 +1423,240 @@ class EXRLoader extends DataTextureLoader {
1461
1423
  }
1462
1424
  }
1463
1425
 
1464
- var bufferDataView = new DataView(buffer);
1465
- var uInt8Array = new Uint8Array(buffer);
1466
- var EXRHeader = {};
1467
- bufferDataView.getUint32(0, true); // magic
1426
+ function parseHeader(dataView, buffer, offset) {
1427
+ const EXRHeader = {};
1428
+ if (dataView.getUint32(0, true) != 20000630) // magic
1429
+ throw "THREE.EXRLoader: provided file doesn't appear to be in OpenEXR format.";
1430
+ EXRHeader.version = dataView.getUint8(4, true);
1431
+ const spec = dataView.getUint8(5, true); // fullMask
1468
1432
 
1469
- bufferDataView.getUint8(4, true); // versionByteZero
1433
+ EXRHeader.spec = {
1434
+ singleTile: !!(spec & 1),
1435
+ longName: !!(spec & 2),
1436
+ deepFormat: !!(spec & 4),
1437
+ multiPart: !!(spec & 8)
1438
+ }; // start of header
1470
1439
 
1471
- bufferDataView.getUint8(5, true); // fullMask
1472
- // start of header
1440
+ offset.value = 8; // start at 8 - after pre-amble
1473
1441
 
1474
- var offset = {
1475
- value: 8
1476
- }; // start at 8, after magic stuff
1442
+ var keepReading = true;
1477
1443
 
1478
- var keepReading = true;
1479
-
1480
- while (keepReading) {
1481
- var attributeName = parseNullTerminatedString(buffer, offset);
1482
-
1483
- if (attributeName == 0) {
1484
- keepReading = false;
1485
- } else {
1486
- var attributeType = parseNullTerminatedString(buffer, offset);
1487
- var attributeSize = parseUint32(bufferDataView, offset);
1488
- var attributeValue = parseValue(bufferDataView, buffer, offset, attributeType, attributeSize);
1444
+ while (keepReading) {
1445
+ var attributeName = parseNullTerminatedString(buffer, offset);
1489
1446
 
1490
- if (attributeValue === undefined) {
1491
- console.warn(`EXRLoader.parse: skipped unknown header attribute type \'${attributeType}\'.`);
1447
+ if (attributeName == 0) {
1448
+ keepReading = false;
1492
1449
  } else {
1493
- EXRHeader[attributeName] = attributeValue;
1450
+ var attributeType = parseNullTerminatedString(buffer, offset);
1451
+ var attributeSize = parseUint32(dataView, offset);
1452
+ var attributeValue = parseValue(dataView, buffer, offset, attributeType, attributeSize);
1453
+
1454
+ if (attributeValue === undefined) {
1455
+ console.warn(`EXRLoader.parse: skipped unknown header attribute type \'${attributeType}\'.`);
1456
+ } else {
1457
+ EXRHeader[attributeName] = attributeValue;
1458
+ }
1494
1459
  }
1495
1460
  }
1496
- } // offsets
1497
-
1498
-
1499
- var dataWindowHeight = EXRHeader.dataWindow.yMax + 1;
1500
- var uncompress;
1501
- var scanlineBlockSize;
1502
-
1503
- switch (EXRHeader.compression) {
1504
- case 'NO_COMPRESSION':
1505
- scanlineBlockSize = 1;
1506
- uncompress = uncompressRAW;
1507
- break;
1508
-
1509
- case 'RLE_COMPRESSION':
1510
- scanlineBlockSize = 1;
1511
- uncompress = uncompressRLE;
1512
- break;
1513
-
1514
- case 'ZIPS_COMPRESSION':
1515
- scanlineBlockSize = 1;
1516
- uncompress = uncompressZIP;
1517
- break;
1518
-
1519
- case 'ZIP_COMPRESSION':
1520
- scanlineBlockSize = 16;
1521
- uncompress = uncompressZIP;
1522
- break;
1523
-
1524
- case 'PIZ_COMPRESSION':
1525
- scanlineBlockSize = 32;
1526
- uncompress = uncompressPIZ;
1527
- break;
1528
-
1529
- case 'PXR24_COMPRESSION':
1530
- scanlineBlockSize = 16;
1531
- uncompress = uncompressPXR;
1532
- break;
1533
-
1534
- case 'DWAA_COMPRESSION':
1535
- scanlineBlockSize = 32;
1536
- uncompress = uncompressDWA;
1537
- break;
1538
-
1539
- case 'DWAB_COMPRESSION':
1540
- scanlineBlockSize = 256;
1541
- uncompress = uncompressDWA;
1542
- break;
1543
-
1544
- default:
1545
- throw 'EXRLoader.parse: ' + EXRHeader.compression + ' is unsupported';
1546
- }
1547
1461
 
1548
- var size_t;
1549
- var getValue; // mixed pixelType not supported
1462
+ if (spec != 0) {
1463
+ console.error('EXRHeader:', EXRHeader);
1464
+ throw 'THREE.EXRLoader: provided file is currently unsupported.';
1465
+ }
1550
1466
 
1551
- var pixelType = EXRHeader.channels[0].pixelType;
1467
+ return EXRHeader;
1468
+ }
1469
+
1470
+ function setupDecoder(EXRHeader, dataView, uInt8Array, offset, outputType) {
1471
+ const EXRDecoder = {
1472
+ size: 0,
1473
+ viewer: dataView,
1474
+ array: uInt8Array,
1475
+ offset: offset,
1476
+ width: EXRHeader.dataWindow.xMax - EXRHeader.dataWindow.xMin + 1,
1477
+ height: EXRHeader.dataWindow.yMax - EXRHeader.dataWindow.yMin + 1,
1478
+ channels: EXRHeader.channels.length,
1479
+ bytesPerLine: null,
1480
+ lines: null,
1481
+ inputSize: null,
1482
+ type: EXRHeader.channels[0].pixelType,
1483
+ uncompress: null,
1484
+ getter: null,
1485
+ format: null,
1486
+ encoding: null
1487
+ };
1552
1488
 
1553
- if (pixelType === 1) {
1554
- // half
1555
- switch (this.type) {
1556
- case UnsignedByteType:
1557
- case FloatType:
1558
- getValue = parseFloat16;
1559
- size_t = INT16_SIZE;
1489
+ switch (EXRHeader.compression) {
1490
+ case 'NO_COMPRESSION':
1491
+ EXRDecoder.lines = 1;
1492
+ EXRDecoder.uncompress = uncompressRAW;
1560
1493
  break;
1561
1494
 
1562
- case HalfFloatType:
1563
- getValue = parseUint16;
1564
- size_t = INT16_SIZE;
1495
+ case 'RLE_COMPRESSION':
1496
+ EXRDecoder.lines = 1;
1497
+ EXRDecoder.uncompress = uncompressRLE;
1565
1498
  break;
1566
- }
1567
- } else if (pixelType === 2) {
1568
- // float
1569
- switch (this.type) {
1570
- case UnsignedByteType:
1571
- case FloatType:
1572
- getValue = parseFloat32;
1573
- size_t = FLOAT32_SIZE;
1499
+
1500
+ case 'ZIPS_COMPRESSION':
1501
+ EXRDecoder.lines = 1;
1502
+ EXRDecoder.uncompress = uncompressZIP;
1574
1503
  break;
1575
1504
 
1576
- case HalfFloatType:
1577
- getValue = decodeFloat32;
1578
- size_t = FLOAT32_SIZE;
1579
- }
1580
- } else {
1581
- throw 'EXRLoader.parse: unsupported pixelType ' + pixelType + ' for ' + EXRHeader.compression + '.';
1582
- }
1505
+ case 'ZIP_COMPRESSION':
1506
+ EXRDecoder.lines = 16;
1507
+ EXRDecoder.uncompress = uncompressZIP;
1508
+ break;
1583
1509
 
1584
- var numBlocks = dataWindowHeight / scanlineBlockSize;
1510
+ case 'PIZ_COMPRESSION':
1511
+ EXRDecoder.lines = 32;
1512
+ EXRDecoder.uncompress = uncompressPIZ;
1513
+ break;
1585
1514
 
1586
- for (var i = 0; i < numBlocks; i++) {
1587
- parseUlong(bufferDataView, offset); // scanlineOffset
1588
- } // we should be passed the scanline offset table, start reading pixel data
1515
+ case 'PXR24_COMPRESSION':
1516
+ EXRDecoder.lines = 16;
1517
+ EXRDecoder.uncompress = uncompressPXR;
1518
+ break;
1589
1519
 
1520
+ case 'DWAA_COMPRESSION':
1521
+ EXRDecoder.lines = 32;
1522
+ EXRDecoder.uncompress = uncompressDWA;
1523
+ break;
1590
1524
 
1591
- var width = EXRHeader.dataWindow.xMax - EXRHeader.dataWindow.xMin + 1;
1592
- var height = EXRHeader.dataWindow.yMax - EXRHeader.dataWindow.yMin + 1; // Firefox only supports RGBA (half) float textures
1593
- // var numChannels = EXRHeader.channels.length;
1525
+ case 'DWAB_COMPRESSION':
1526
+ EXRDecoder.lines = 256;
1527
+ EXRDecoder.uncompress = uncompressDWA;
1528
+ break;
1529
+
1530
+ default:
1531
+ throw 'EXRLoader.parse: ' + EXRHeader.compression + ' is unsupported';
1532
+ }
1594
1533
 
1595
- var numChannels = 4;
1596
- var size = width * height * numChannels; // Fill initially with 1s for the alpha value if the texture is not RGBA, RGB values will be overwritten
1534
+ EXRDecoder.scanlineBlockSize = EXRDecoder.lines;
1597
1535
 
1598
- switch (this.type) {
1599
- case UnsignedByteType:
1600
- case FloatType:
1601
- var byteArray = new Float32Array(size);
1536
+ if (EXRDecoder.type == 1) {
1537
+ // half
1538
+ switch (outputType) {
1539
+ case FloatType:
1540
+ EXRDecoder.getter = parseFloat16;
1541
+ EXRDecoder.inputSize = INT16_SIZE;
1542
+ break;
1602
1543
 
1603
- if (EXRHeader.channels.length < numChannels) {
1604
- byteArray.fill(1, 0, size);
1544
+ case HalfFloatType:
1545
+ EXRDecoder.getter = parseUint16;
1546
+ EXRDecoder.inputSize = INT16_SIZE;
1547
+ break;
1605
1548
  }
1549
+ } else if (EXRDecoder.type == 2) {
1550
+ // float
1551
+ switch (outputType) {
1552
+ case FloatType:
1553
+ EXRDecoder.getter = parseFloat32;
1554
+ EXRDecoder.inputSize = FLOAT32_SIZE;
1555
+ break;
1606
1556
 
1607
- break;
1557
+ case HalfFloatType:
1558
+ EXRDecoder.getter = decodeFloat32;
1559
+ EXRDecoder.inputSize = FLOAT32_SIZE;
1560
+ }
1561
+ } else {
1562
+ throw 'EXRLoader.parse: unsupported pixelType ' + EXRDecoder.type + ' for ' + EXRHeader.compression + '.';
1563
+ }
1608
1564
 
1609
- case HalfFloatType:
1610
- var byteArray = new Uint16Array(size);
1565
+ EXRDecoder.blockCount = (EXRHeader.dataWindow.yMax + 1) / EXRDecoder.scanlineBlockSize;
1611
1566
 
1612
- if (EXRHeader.channels.length < numChannels) {
1613
- byteArray.fill(0x3c00, 0, size); // Uint16Array holds half float data, 0x3C00 is 1
1614
- }
1567
+ for (var i = 0; i < EXRDecoder.blockCount; i++) parseInt64(dataView, offset); // scanlineOffset
1568
+ // we should be passed the scanline offset table, ready to start reading pixel data.
1569
+ // RGB images will be converted to RGBA format, preventing software emulation in select devices.
1615
1570
 
1616
- break;
1617
1571
 
1618
- default:
1619
- console.error('THREE.EXRLoader: unsupported type: ', this.type);
1620
- break;
1621
- }
1572
+ EXRDecoder.outputChannels = EXRDecoder.channels == 3 ? 4 : EXRDecoder.channels;
1573
+ const size = EXRDecoder.width * EXRDecoder.height * EXRDecoder.outputChannels;
1574
+
1575
+ switch (outputType) {
1576
+ case FloatType:
1577
+ EXRDecoder.byteArray = new Float32Array(size); // Fill initially with 1s for the alpha value if the texture is not RGBA, RGB values will be overwritten
1578
+
1579
+ if (EXRDecoder.channels < EXRDecoder.outputChannels) EXRDecoder.byteArray.fill(1, 0, size);
1580
+ break;
1581
+
1582
+ case HalfFloatType:
1583
+ EXRDecoder.byteArray = new Uint16Array(size);
1584
+ if (EXRDecoder.channels < EXRDecoder.outputChannels) EXRDecoder.byteArray.fill(0x3c00, 0, size); // Uint16Array holds half float data, 0x3C00 is 1
1585
+
1586
+ break;
1587
+
1588
+ default:
1589
+ console.error('THREE.EXRLoader: unsupported type: ', outputType);
1590
+ break;
1591
+ }
1592
+
1593
+ EXRDecoder.bytesPerLine = EXRDecoder.width * EXRDecoder.inputSize * EXRDecoder.channels;
1594
+
1595
+ if (EXRDecoder.outputChannels == 4) {
1596
+ EXRDecoder.format = RGBAFormat;
1597
+ EXRDecoder.encoding = LinearEncoding;
1598
+ } else {
1599
+ EXRDecoder.format = RedFormat;
1600
+ EXRDecoder.encoding = LinearEncoding;
1601
+ }
1602
+
1603
+ return EXRDecoder;
1604
+ } // start parsing file [START]
1605
+
1606
+
1607
+ const bufferDataView = new DataView(buffer);
1608
+ const uInt8Array = new Uint8Array(buffer);
1609
+ const offset = {
1610
+ value: 0
1611
+ }; // get header information and validate format.
1612
+
1613
+ const EXRHeader = parseHeader(bufferDataView, buffer, offset); // get input compression information and prepare decoding.
1622
1614
 
1623
- var channelOffsets = {
1615
+ const EXRDecoder = setupDecoder(EXRHeader, bufferDataView, uInt8Array, offset, this.type);
1616
+ const tmpOffset = {
1617
+ value: 0
1618
+ };
1619
+ const channelOffsets = {
1624
1620
  R: 0,
1625
1621
  G: 1,
1626
1622
  B: 2,
1627
- A: 3
1628
- };
1629
- var compressionInfo = {
1630
- size: 0,
1631
- width: width,
1632
- lines: scanlineBlockSize,
1633
- offset: offset,
1634
- array: uInt8Array,
1635
- viewer: bufferDataView,
1636
- type: pixelType,
1637
- channels: EXRHeader.channels.length
1638
- };
1639
- var line;
1640
- var size;
1641
- var viewer;
1642
- var tmpOffset = {
1643
- value: 0
1623
+ A: 3,
1624
+ Y: 0
1644
1625
  };
1645
1626
 
1646
- for (var scanlineBlockIdx = 0; scanlineBlockIdx < height / scanlineBlockSize; scanlineBlockIdx++) {
1647
- line = parseUint32(bufferDataView, offset); // line_no
1627
+ for (let scanlineBlockIdx = 0; scanlineBlockIdx < EXRDecoder.height / EXRDecoder.scanlineBlockSize; scanlineBlockIdx++) {
1628
+ const line = parseUint32(bufferDataView, offset); // line_no
1648
1629
 
1649
- size = parseUint32(bufferDataView, offset); // data_len
1630
+ EXRDecoder.size = parseUint32(bufferDataView, offset); // data_len
1650
1631
 
1651
- compressionInfo.lines = line + scanlineBlockSize > height ? height - line : scanlineBlockSize;
1652
- compressionInfo.offset = offset;
1653
- compressionInfo.size = size;
1654
- viewer = uncompress(compressionInfo);
1655
- offset.value += size;
1632
+ EXRDecoder.lines = line + EXRDecoder.scanlineBlockSize > EXRDecoder.height ? EXRDecoder.height - line : EXRDecoder.scanlineBlockSize;
1633
+ const isCompressed = EXRDecoder.size < EXRDecoder.lines * EXRDecoder.bytesPerLine;
1634
+ const viewer = isCompressed ? EXRDecoder.uncompress(EXRDecoder) : uncompressRAW(EXRDecoder);
1635
+ offset.value += EXRDecoder.size;
1656
1636
 
1657
- for (var line_y = 0; line_y < scanlineBlockSize; line_y++) {
1658
- var true_y = line_y + scanlineBlockIdx * scanlineBlockSize;
1659
- if (true_y >= height) break;
1637
+ for (let line_y = 0; line_y < EXRDecoder.scanlineBlockSize; line_y++) {
1638
+ const true_y = line_y + scanlineBlockIdx * EXRDecoder.scanlineBlockSize;
1639
+ if (true_y >= EXRDecoder.height) break;
1660
1640
 
1661
- for (var channelID = 0; channelID < EXRHeader.channels.length; channelID++) {
1662
- var cOff = channelOffsets[EXRHeader.channels[channelID].name];
1641
+ for (let channelID = 0; channelID < EXRDecoder.channels; channelID++) {
1642
+ const cOff = channelOffsets[EXRHeader.channels[channelID].name];
1663
1643
 
1664
- for (var x = 0; x < width; x++) {
1665
- var idx = line_y * (EXRHeader.channels.length * width) + channelID * width + x;
1666
- tmpOffset.value = idx * size_t;
1667
- var val = getValue(viewer, tmpOffset);
1668
- byteArray[(height - 1 - true_y) * (width * numChannels) + x * numChannels + cOff] = val;
1644
+ for (let x = 0; x < EXRDecoder.width; x++) {
1645
+ tmpOffset.value = (line_y * (EXRDecoder.channels * EXRDecoder.width) + channelID * EXRDecoder.width + x) * EXRDecoder.inputSize;
1646
+ const outIndex = (EXRDecoder.height - 1 - true_y) * (EXRDecoder.width * EXRDecoder.outputChannels) + x * EXRDecoder.outputChannels + cOff;
1647
+ EXRDecoder.byteArray[outIndex] = EXRDecoder.getter(viewer, tmpOffset);
1669
1648
  }
1670
1649
  }
1671
1650
  }
1672
1651
  }
1673
1652
 
1674
- if (this.type === UnsignedByteType) {
1675
- let v, i;
1676
- const size = byteArray.length;
1677
- const RGBEArray = new Uint8Array(size);
1678
-
1679
- for (let h = 0; h < height; ++h) {
1680
- for (let w = 0; w < width; ++w) {
1681
- i = h * width * 4 + w * 4;
1682
- const red = byteArray[i];
1683
- const green = byteArray[i + 1];
1684
- const blue = byteArray[i + 2];
1685
- v = red > green ? red : green;
1686
- v = blue > v ? blue : v;
1687
-
1688
- if (v < 1e-32) {
1689
- RGBEArray[i] = RGBEArray[i + 1] = RGBEArray[i + 2] = RGBEArray[i + 3] = 0;
1690
- } else {
1691
- const res = frexp(v);
1692
- v = res[0] * 256 / v;
1693
- RGBEArray[i] = red * v;
1694
- RGBEArray[i + 1] = green * v;
1695
- RGBEArray[i + 2] = blue * v;
1696
- RGBEArray[i + 3] = res[1] + 128;
1697
- }
1698
- }
1699
- }
1700
-
1701
- byteArray = RGBEArray;
1702
- }
1703
-
1704
- const format = this.type === UnsignedByteType ? RGBEFormat : RGBAFormat ;
1705
1653
  return {
1706
1654
  header: EXRHeader,
1707
- width: width,
1708
- height: height,
1709
- data: byteArray,
1710
- format: format,
1655
+ width: EXRDecoder.width,
1656
+ height: EXRDecoder.height,
1657
+ data: EXRDecoder.byteArray,
1658
+ format: EXRDecoder.format,
1659
+ encoding: EXRDecoder.encoding,
1711
1660
  type: this.type
1712
1661
  };
1713
1662
  }
@@ -1719,25 +1668,11 @@ class EXRLoader extends DataTextureLoader {
1719
1668
 
1720
1669
  load(url, onLoad, onProgress, onError) {
1721
1670
  function onLoadCallback(texture, texData) {
1722
- switch (texture.type) {
1723
- case UnsignedByteType:
1724
- texture.encoding = RGBEEncoding;
1725
- texture.minFilter = NearestFilter;
1726
- texture.magFilter = NearestFilter;
1727
- texture.generateMipmaps = false;
1728
- texture.flipY = false;
1729
- break;
1730
-
1731
- case FloatType:
1732
- case HalfFloatType:
1733
- texture.encoding = LinearEncoding;
1734
- texture.minFilter = LinearFilter;
1735
- texture.magFilter = LinearFilter;
1736
- texture.generateMipmaps = false;
1737
- texture.flipY = false;
1738
- break;
1739
- }
1740
-
1671
+ texture.encoding = texData.encoding;
1672
+ texture.minFilter = LinearFilter;
1673
+ texture.magFilter = LinearFilter;
1674
+ texture.generateMipmaps = false;
1675
+ texture.flipY = false;
1741
1676
  if (onLoad) onLoad(texture, texData);
1742
1677
  }
1743
1678