@galacean/engine-loader 2.0.0-alpha.60 → 2.0.0-alpha.61

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.
package/dist/module.js CHANGED
@@ -886,7 +886,7 @@ var ReflectionParser = /*#__PURE__*/ function() {
886
886
  * HDR (Radiance RGBE) image decoder.
887
887
  *
888
888
  * Decodes .hdr files into pixel data. Supports parsing the header
889
- * and decoding RLE-compressed RGBE scanlines into R16G16B16A16 half-float pixels.
889
+ * and decoding RLE-compressed RGBE scanlines into R16G16B16A16_SFloat half-float pixels.
890
890
  */ var HDRDecoder = /*#__PURE__*/ function() {
891
891
  function HDRDecoder() {}
892
892
  /**
@@ -927,7 +927,7 @@ var ReflectionParser = /*#__PURE__*/ function() {
927
927
  };
928
928
  };
929
929
  /**
930
- * Decode an HDR file buffer into R16G16B16A16 half-float pixel data.
930
+ * Decode an HDR file buffer into R16G16B16A16_SFloat half-float pixel data.
931
931
  * @param buffer - The full HDR file as Uint8Array.
932
932
  * @returns Object with width, height, and half-float pixel data.
933
933
  */ HDRDecoder.decode = function decode(buffer) {
@@ -943,7 +943,7 @@ var ReflectionParser = /*#__PURE__*/ function() {
943
943
  };
944
944
  /**
945
945
  * @internal
946
- * Convert RGBE pixel data to R16G16B16A16 half-float.
946
+ * Convert RGBE pixel data to R16G16B16A16_SFloat half-float.
947
947
  */ HDRDecoder._rgbeToHalfFloat = function _rgbeToHalfFloat(rgbe, width, height) {
948
948
  var floatView = this._floatView;
949
949
  var uint32View = this._uint32View;
@@ -1145,7 +1145,7 @@ function _instanceof(left, right) {
1145
1145
  var isSRGBColorSpace = !!bufferReader.nextUint8();
1146
1146
  var imageData = bufferReader.nextImagesData(1)[0];
1147
1147
  var isHDR = imageData[0] === 0x23 && imageData[1] === 0x3f;
1148
- var textureFormat = isHDR ? TextureFormat.R16G16B16A16 : format;
1148
+ var textureFormat = isHDR ? TextureFormat.R16G16B16A16_SFloat : format;
1149
1149
  var texture = restoredTexture || new Texture2D(engine, width, height, textureFormat, mipmap, isHDR ? false : isSRGBColorSpace);
1150
1150
  texture.filterMode = filterMode;
1151
1151
  texture.anisoLevel = anisoLevel;
@@ -1190,7 +1190,7 @@ Texture2DDecoder = __decorate([
1190
1190
  var facesData = bufferReader.nextImagesData(6);
1191
1191
  // Detect format by first face's magic bytes
1192
1192
  var isHDR = facesData[0][0] === 0x23 && facesData[0][1] === 0x3f;
1193
- var textureFormat = isHDR ? TextureFormat.R16G16B16A16 : format;
1193
+ var textureFormat = isHDR ? TextureFormat.R16G16B16A16_SFloat : format;
1194
1194
  var texture = restoredTexture || new TextureCube(engine, faceSize, textureFormat, mipmap, isSRGBColorSpace);
1195
1195
  texture.filterMode = filterMode;
1196
1196
  texture.anisoLevel = anisoLevel;
@@ -1977,12 +1977,12 @@ var ColorModel = /*#__PURE__*/ function(ColorModel) {
1977
1977
  /** RGB(A) compressed format, 4 bits per pixel if no alpha channel, 8 bits per pixel if has alpha channel. */ KTX2TargetFormat[KTX2TargetFormat["BC1_BC3"] = 2] = "BC1_BC3";
1978
1978
  /** RGB(A) compressed format, 4 bits per pixel. */ KTX2TargetFormat[KTX2TargetFormat["PVRTC"] = 3] = "PVRTC";
1979
1979
  /** RGB(A) compressed format, 4 bits per pixel if no alpha channel, 8 bits per pixel if has alpha channel. */ KTX2TargetFormat[KTX2TargetFormat["ETC"] = 4] = "ETC";
1980
- /** R format, 8 bits per pixel. */ KTX2TargetFormat[KTX2TargetFormat["R8"] = 5] = "R8";
1981
- /** RG format, 16 bits per pixel. */ KTX2TargetFormat[KTX2TargetFormat["R8G8"] = 6] = "R8G8";
1982
- /** RGBA format, 32 bits per pixel. */ KTX2TargetFormat[KTX2TargetFormat["R8G8B8A8"] = 7] = "R8G8B8A8";
1980
+ /** R 8-bit unsigned normalized format. */ KTX2TargetFormat[KTX2TargetFormat["R8_UNorm"] = 5] = "R8_UNorm";
1981
+ /** RG 8-bit unsigned normalized format. */ KTX2TargetFormat[KTX2TargetFormat["R8G8_UNorm"] = 6] = "R8G8_UNorm";
1982
+ /** RGBA 8-bit unsigned normalized format. */ KTX2TargetFormat[KTX2TargetFormat["R8G8B8A8_UNorm"] = 7] = "R8G8B8A8_UNorm";
1983
1983
  /** RGB HDR compressed format, 8 bits per pixel. */ KTX2TargetFormat[KTX2TargetFormat["BC6H"] = 8] = "BC6H";
1984
1984
  /** HDR RGB(A) compressed format, 128 bits per 4x4 pixel block (currently UASTC HDR 4x4 encoders are only RGB). */ KTX2TargetFormat[KTX2TargetFormat["ASTC_HDR_4x4"] = 9] = "ASTC_HDR_4x4";
1985
- /** RGBA format, 16 bits per channel. */ KTX2TargetFormat[KTX2TargetFormat["R16G16B16A16"] = 10] = "R16G16B16A16";
1985
+ /** RGBA 16-bit signed float format. */ KTX2TargetFormat[KTX2TargetFormat["R16G16B16A16_SFloat"] = 10] = "R16G16B16A16_SFloat";
1986
1986
  return KTX2TargetFormat;
1987
1987
  }({});
1988
1988
 
@@ -2457,11 +2457,11 @@ var KTX2Loader = /*#__PURE__*/ function(Loader) {
2457
2457
  var targetFormat = this._detectSupportedFormat(renderer, priorityFormats, isSRGB);
2458
2458
  if (targetFormat === KTX2TargetFormat.PVRTC && (!MathUtil.isPowerOf2(pixelWidth) || !MathUtil.isPowerOf2(pixelHeight) || pixelWidth !== pixelHeight)) {
2459
2459
  Logger.warn("PVRTC image need power of 2 and width===height, downgrade to RGBA8");
2460
- return KTX2TargetFormat.R8G8B8A8;
2460
+ return KTX2TargetFormat.R8G8B8A8_UNorm;
2461
2461
  }
2462
2462
  if (targetFormat === null) {
2463
2463
  Logger.warn("Can't support any compressed texture, downgrade to RGBA8");
2464
- return KTX2TargetFormat.R8G8B8A8;
2464
+ return KTX2TargetFormat.R8G8B8A8_UNorm;
2465
2465
  }
2466
2466
  return targetFormat;
2467
2467
  };
@@ -2474,12 +2474,12 @@ var KTX2Loader = /*#__PURE__*/ function(Loader) {
2474
2474
  if (renderer.canIUse(capability)) return format;
2475
2475
  } else {
2476
2476
  switch(priorityFormats[i]){
2477
- case KTX2TargetFormat.R8G8B8A8:
2477
+ case KTX2TargetFormat.R8G8B8A8_UNorm:
2478
2478
  return format;
2479
- case KTX2TargetFormat.R8:
2480
- case KTX2TargetFormat.R8G8:
2479
+ case KTX2TargetFormat.R8_UNorm:
2480
+ case KTX2TargetFormat.R8G8_UNorm:
2481
2481
  return format;
2482
- case KTX2TargetFormat.R16G16B16A16:
2482
+ case KTX2TargetFormat.R16G16B16A16_SFloat:
2483
2483
  if (!isSRGB) return format;
2484
2484
  }
2485
2485
  }
@@ -2504,14 +2504,14 @@ var KTX2Loader = /*#__PURE__*/ function(Loader) {
2504
2504
  return hasAlpha ? TextureFormat.BC3 : TextureFormat.BC1;
2505
2505
  case KTX2TargetFormat.PVRTC:
2506
2506
  return hasAlpha ? TextureFormat.PVRTC_RGBA4 : TextureFormat.PVRTC_RGB4;
2507
- case KTX2TargetFormat.R8G8B8A8:
2508
- return TextureFormat.R8G8B8A8;
2507
+ case KTX2TargetFormat.R8G8B8A8_UNorm:
2508
+ return TextureFormat.R8G8B8A8_UNorm;
2509
2509
  case KTX2TargetFormat.BC6H:
2510
2510
  return TextureFormat.BC6H;
2511
2511
  case KTX2TargetFormat.ASTC_HDR_4x4:
2512
2512
  return TextureFormat.ASTC_4x4;
2513
- case KTX2TargetFormat.R16G16B16A16:
2514
- return TextureFormat.R16G16B16A16;
2513
+ case KTX2TargetFormat.R16G16B16A16_SFloat:
2514
+ return TextureFormat.R16G16B16A16_SFloat;
2515
2515
  }
2516
2516
  };
2517
2517
  return KTX2Loader;
@@ -2532,7 +2532,7 @@ KTX2Loader._priorityFormats = (_obj$2 = {}, _obj$2[ColorModel.ETC1S] = [
2532
2532
  ], _obj$2[ColorModel.UASTC_HDR_4X4] = [
2533
2533
  KTX2TargetFormat.ASTC_HDR_4x4,
2534
2534
  KTX2TargetFormat.BC6H,
2535
- KTX2TargetFormat.R16G16B16A16
2535
+ KTX2TargetFormat.R16G16B16A16_SFloat
2536
2536
  ], _obj$2);
2537
2537
  var _obj1$1, _obj2, _obj3, _obj4, _obj5, _obj6, _obj7, _obj8;
2538
2538
  KTX2Loader._capabilityMap = (_obj8 = {}, _obj8[KTX2TargetFormat.ASTC] = (_obj1$1 = {}, _obj1$1[DFDTransferFunction.linear] = GLCapabilityType.astc, _obj1$1[DFDTransferFunction.sRGB] = GLCapabilityType.astc, _obj1$1), _obj8[KTX2TargetFormat.ETC] = (_obj2 = {}, _obj2[DFDTransferFunction.linear] = GLCapabilityType.etc, _obj2[DFDTransferFunction.sRGB] = GLCapabilityType.etc, _obj2), _obj8[KTX2TargetFormat.BC7] = (_obj3 = {}, _obj3[DFDTransferFunction.linear] = GLCapabilityType.bptc, _obj3[DFDTransferFunction.sRGB] = GLCapabilityType.bptc, _obj3), _obj8[KTX2TargetFormat.BC1_BC3] = (_obj4 = {}, _obj4[DFDTransferFunction.linear] = GLCapabilityType.s3tc, _obj4[DFDTransferFunction.sRGB] = GLCapabilityType.s3tc_srgb, _obj4), _obj8[KTX2TargetFormat.BC6H] = (_obj5 = {}, _obj5[DFDTransferFunction.linear] = GLCapabilityType.bptc, _obj5), _obj8[KTX2TargetFormat.ASTC_HDR_4x4] = (_obj6 = {}, _obj6[DFDTransferFunction.linear] = GLCapabilityType.astc_hdr, _obj6), _obj8[KTX2TargetFormat.PVRTC] = (_obj7 = {}, _obj7[DFDTransferFunction.linear] = GLCapabilityType.pvrtc, _obj7), _obj8);
@@ -2606,7 +2606,7 @@ var AmbientLightLoader = /*#__PURE__*/ function(Loader) {
2606
2606
  });
2607
2607
  } else {
2608
2608
  var size = new Uint16Array(buffer, textureOffset, 1)[0];
2609
- texture || (texture = new TextureCube(engine, size, TextureFormat.R16G16B16A16, true, false));
2609
+ texture || (texture = new TextureCube(engine, size, TextureFormat.R16G16B16A16_SFloat, true, false));
2610
2610
  texture.filterMode = TextureFilterMode.Trilinear;
2611
2611
  var mipmapCount = texture.mipmapCount;
2612
2612
  var offset = textureOffset + 2;
@@ -5033,7 +5033,7 @@ var GLTFTextureParser = /*#__PURE__*/ function(GLTFParser1) {
5033
5033
  var imageBuffer = new Uint8Array(buffer, (_bufferView_byteOffset = bufferView.byteOffset) != null ? _bufferView_byteOffset : 0, bufferView.byteLength);
5034
5034
  return ImageDecoder._decode(imageBuffer, imageName || textureName || url, mimeType).then(function(image) {
5035
5035
  var width = image.width, height = image.height;
5036
- var format = TextureFormat.R8G8B8A8;
5036
+ var format = TextureFormat.R8G8B8A8_UNorm;
5037
5037
  var _samplerInfo_mipmap;
5038
5038
  var generateMipmap = TextureUtils.supportGenerateMipmapsWithCorrection(format, (_samplerInfo_mipmap = samplerInfo == null ? void 0 : samplerInfo.mipmap) != null ? _samplerInfo_mipmap : true, isSRGBColorSpace);
5039
5039
  var texture = new Texture2D(engine, width, height, format, generateMipmap, isSRGBColorSpace);
@@ -6101,14 +6101,14 @@ var TextureLoader = /*#__PURE__*/ function(Loader) {
6101
6101
  var _this = this;
6102
6102
  return new AssetPromise(function(resolve, reject) {
6103
6103
  var engine = resourceManager.engine;
6104
- if (!SystemInfo.supportsTextureFormat(engine, TextureFormat.R16G16B16A16)) {
6104
+ if (!SystemInfo.supportsTextureFormat(engine, TextureFormat.R16G16B16A16_SFloat)) {
6105
6105
  reject(new Error("TextureLoader: HDR texture requires half float support."));
6106
6106
  return;
6107
6107
  }
6108
6108
  var _HDRDecoder_decode = HDRDecoder.decode(buffer), width = _HDRDecoder_decode.width, height = _HDRDecoder_decode.height, pixels = _HDRDecoder_decode.pixels;
6109
6109
  var _item_params;
6110
6110
  var _ref = (_item_params = item.params) != null ? _item_params : {}, _ref_mipmap = _ref.mipmap, mipmap = _ref_mipmap === void 0 ? true : _ref_mipmap;
6111
- var texture = new Texture2D(engine, width, height, TextureFormat.R16G16B16A16, mipmap, false);
6111
+ var texture = new Texture2D(engine, width, height, TextureFormat.R16G16B16A16_SFloat, mipmap, false);
6112
6112
  texture.setPixelBuffer(pixels);
6113
6113
  mipmap && texture.generateMipmaps();
6114
6114
  _this._applyParams(texture, item);
@@ -6119,7 +6119,7 @@ var TextureLoader = /*#__PURE__*/ function(Loader) {
6119
6119
  var _this = this;
6120
6120
  return ImageDecoder._decode(buffer, item.url).then(function(img) {
6121
6121
  var _item_params;
6122
- var _ref = (_item_params = item.params) != null ? _item_params : {}, _ref_format = _ref.format, format = _ref_format === void 0 ? TextureFormat.R8G8B8A8 : _ref_format, _ref_isSRGBColorSpace = _ref.isSRGBColorSpace, isSRGBColorSpace = _ref_isSRGBColorSpace === void 0 ? true : _ref_isSRGBColorSpace, _ref_mipmap = _ref.mipmap, mipmap = _ref_mipmap === void 0 ? true : _ref_mipmap;
6122
+ var _ref = (_item_params = item.params) != null ? _item_params : {}, _ref_format = _ref.format, format = _ref_format === void 0 ? TextureFormat.R8G8B8A8_UNorm : _ref_format, _ref_isSRGBColorSpace = _ref.isSRGBColorSpace, isSRGBColorSpace = _ref_isSRGBColorSpace === void 0 ? true : _ref_isSRGBColorSpace, _ref_mipmap = _ref.mipmap, mipmap = _ref_mipmap === void 0 ? true : _ref_mipmap;
6123
6123
  var engine = resourceManager.engine;
6124
6124
  var width = img.width, height = img.height;
6125
6125
  var generateMipmap = TextureUtils.supportGenerateMipmapsWithCorrection(format, mipmap, isSRGBColorSpace);
@@ -6322,7 +6322,7 @@ var RenderTargetLoader = /*#__PURE__*/ function(Loader) {
6322
6322
  var _props_mipmap;
6323
6323
  var mipmap = (_props_mipmap = props == null ? void 0 : props.mipmap) != null ? _props_mipmap : true;
6324
6324
  var _props_isSRGBColorSpace;
6325
- var isSRGB = (_props_isSRGBColorSpace = props == null ? void 0 : props.isSRGBColorSpace) != null ? _props_isSRGBColorSpace : format === TextureFormat.R8G8B8A8;
6325
+ var isSRGB = (_props_isSRGBColorSpace = props == null ? void 0 : props.isSRGBColorSpace) != null ? _props_isSRGBColorSpace : format === TextureFormat.R8G8B8A8_UNorm;
6326
6326
  var texture = new Texture2D(engine, width, height, format, mipmap, isSRGB);
6327
6327
  if (props) {
6328
6328
  if (props.filterMode != null) texture.filterMode = props.filterMode;