@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/main.js CHANGED
@@ -890,7 +890,7 @@ var ReflectionParser = /*#__PURE__*/ function() {
890
890
  * HDR (Radiance RGBE) image decoder.
891
891
  *
892
892
  * Decodes .hdr files into pixel data. Supports parsing the header
893
- * and decoding RLE-compressed RGBE scanlines into R16G16B16A16 half-float pixels.
893
+ * and decoding RLE-compressed RGBE scanlines into R16G16B16A16_SFloat half-float pixels.
894
894
  */ var HDRDecoder = /*#__PURE__*/ function() {
895
895
  function HDRDecoder() {}
896
896
  /**
@@ -931,7 +931,7 @@ var ReflectionParser = /*#__PURE__*/ function() {
931
931
  };
932
932
  };
933
933
  /**
934
- * Decode an HDR file buffer into R16G16B16A16 half-float pixel data.
934
+ * Decode an HDR file buffer into R16G16B16A16_SFloat half-float pixel data.
935
935
  * @param buffer - The full HDR file as Uint8Array.
936
936
  * @returns Object with width, height, and half-float pixel data.
937
937
  */ HDRDecoder.decode = function decode(buffer) {
@@ -947,7 +947,7 @@ var ReflectionParser = /*#__PURE__*/ function() {
947
947
  };
948
948
  /**
949
949
  * @internal
950
- * Convert RGBE pixel data to R16G16B16A16 half-float.
950
+ * Convert RGBE pixel data to R16G16B16A16_SFloat half-float.
951
951
  */ HDRDecoder._rgbeToHalfFloat = function _rgbeToHalfFloat(rgbe, width, height) {
952
952
  var floatView = this._floatView;
953
953
  var uint32View = this._uint32View;
@@ -1149,7 +1149,7 @@ function _instanceof(left, right) {
1149
1149
  var isSRGBColorSpace = !!bufferReader.nextUint8();
1150
1150
  var imageData = bufferReader.nextImagesData(1)[0];
1151
1151
  var isHDR = imageData[0] === 0x23 && imageData[1] === 0x3f;
1152
- var textureFormat = isHDR ? engineCore.TextureFormat.R16G16B16A16 : format;
1152
+ var textureFormat = isHDR ? engineCore.TextureFormat.R16G16B16A16_SFloat : format;
1153
1153
  var texture = restoredTexture || new engineCore.Texture2D(engine, width, height, textureFormat, mipmap, isHDR ? false : isSRGBColorSpace);
1154
1154
  texture.filterMode = filterMode;
1155
1155
  texture.anisoLevel = anisoLevel;
@@ -1194,7 +1194,7 @@ Texture2DDecoder = __decorate([
1194
1194
  var facesData = bufferReader.nextImagesData(6);
1195
1195
  // Detect format by first face's magic bytes
1196
1196
  var isHDR = facesData[0][0] === 0x23 && facesData[0][1] === 0x3f;
1197
- var textureFormat = isHDR ? engineCore.TextureFormat.R16G16B16A16 : format;
1197
+ var textureFormat = isHDR ? engineCore.TextureFormat.R16G16B16A16_SFloat : format;
1198
1198
  var texture = restoredTexture || new engineCore.TextureCube(engine, faceSize, textureFormat, mipmap, isSRGBColorSpace);
1199
1199
  texture.filterMode = filterMode;
1200
1200
  texture.anisoLevel = anisoLevel;
@@ -1981,12 +1981,12 @@ var ColorModel = /*#__PURE__*/ function(ColorModel) {
1981
1981
  /** 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";
1982
1982
  /** RGB(A) compressed format, 4 bits per pixel. */ KTX2TargetFormat[KTX2TargetFormat["PVRTC"] = 3] = "PVRTC";
1983
1983
  /** 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";
1984
- /** R format, 8 bits per pixel. */ KTX2TargetFormat[KTX2TargetFormat["R8"] = 5] = "R8";
1985
- /** RG format, 16 bits per pixel. */ KTX2TargetFormat[KTX2TargetFormat["R8G8"] = 6] = "R8G8";
1986
- /** RGBA format, 32 bits per pixel. */ KTX2TargetFormat[KTX2TargetFormat["R8G8B8A8"] = 7] = "R8G8B8A8";
1984
+ /** R 8-bit unsigned normalized format. */ KTX2TargetFormat[KTX2TargetFormat["R8_UNorm"] = 5] = "R8_UNorm";
1985
+ /** RG 8-bit unsigned normalized format. */ KTX2TargetFormat[KTX2TargetFormat["R8G8_UNorm"] = 6] = "R8G8_UNorm";
1986
+ /** RGBA 8-bit unsigned normalized format. */ KTX2TargetFormat[KTX2TargetFormat["R8G8B8A8_UNorm"] = 7] = "R8G8B8A8_UNorm";
1987
1987
  /** RGB HDR compressed format, 8 bits per pixel. */ KTX2TargetFormat[KTX2TargetFormat["BC6H"] = 8] = "BC6H";
1988
1988
  /** 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";
1989
- /** RGBA format, 16 bits per channel. */ KTX2TargetFormat[KTX2TargetFormat["R16G16B16A16"] = 10] = "R16G16B16A16";
1989
+ /** RGBA 16-bit signed float format. */ KTX2TargetFormat[KTX2TargetFormat["R16G16B16A16_SFloat"] = 10] = "R16G16B16A16_SFloat";
1990
1990
  return KTX2TargetFormat;
1991
1991
  }({});
1992
1992
 
@@ -2461,11 +2461,11 @@ exports.KTX2Loader = /*#__PURE__*/ function(Loader) {
2461
2461
  var targetFormat = this._detectSupportedFormat(renderer, priorityFormats, isSRGB);
2462
2462
  if (targetFormat === KTX2TargetFormat.PVRTC && (!engineMath.MathUtil.isPowerOf2(pixelWidth) || !engineMath.MathUtil.isPowerOf2(pixelHeight) || pixelWidth !== pixelHeight)) {
2463
2463
  engineCore.Logger.warn("PVRTC image need power of 2 and width===height, downgrade to RGBA8");
2464
- return KTX2TargetFormat.R8G8B8A8;
2464
+ return KTX2TargetFormat.R8G8B8A8_UNorm;
2465
2465
  }
2466
2466
  if (targetFormat === null) {
2467
2467
  engineCore.Logger.warn("Can't support any compressed texture, downgrade to RGBA8");
2468
- return KTX2TargetFormat.R8G8B8A8;
2468
+ return KTX2TargetFormat.R8G8B8A8_UNorm;
2469
2469
  }
2470
2470
  return targetFormat;
2471
2471
  };
@@ -2478,12 +2478,12 @@ exports.KTX2Loader = /*#__PURE__*/ function(Loader) {
2478
2478
  if (renderer.canIUse(capability)) return format;
2479
2479
  } else {
2480
2480
  switch(priorityFormats[i]){
2481
- case KTX2TargetFormat.R8G8B8A8:
2481
+ case KTX2TargetFormat.R8G8B8A8_UNorm:
2482
2482
  return format;
2483
- case KTX2TargetFormat.R8:
2484
- case KTX2TargetFormat.R8G8:
2483
+ case KTX2TargetFormat.R8_UNorm:
2484
+ case KTX2TargetFormat.R8G8_UNorm:
2485
2485
  return format;
2486
- case KTX2TargetFormat.R16G16B16A16:
2486
+ case KTX2TargetFormat.R16G16B16A16_SFloat:
2487
2487
  if (!isSRGB) return format;
2488
2488
  }
2489
2489
  }
@@ -2508,14 +2508,14 @@ exports.KTX2Loader = /*#__PURE__*/ function(Loader) {
2508
2508
  return hasAlpha ? engineCore.TextureFormat.BC3 : engineCore.TextureFormat.BC1;
2509
2509
  case KTX2TargetFormat.PVRTC:
2510
2510
  return hasAlpha ? engineCore.TextureFormat.PVRTC_RGBA4 : engineCore.TextureFormat.PVRTC_RGB4;
2511
- case KTX2TargetFormat.R8G8B8A8:
2512
- return engineCore.TextureFormat.R8G8B8A8;
2511
+ case KTX2TargetFormat.R8G8B8A8_UNorm:
2512
+ return engineCore.TextureFormat.R8G8B8A8_UNorm;
2513
2513
  case KTX2TargetFormat.BC6H:
2514
2514
  return engineCore.TextureFormat.BC6H;
2515
2515
  case KTX2TargetFormat.ASTC_HDR_4x4:
2516
2516
  return engineCore.TextureFormat.ASTC_4x4;
2517
- case KTX2TargetFormat.R16G16B16A16:
2518
- return engineCore.TextureFormat.R16G16B16A16;
2517
+ case KTX2TargetFormat.R16G16B16A16_SFloat:
2518
+ return engineCore.TextureFormat.R16G16B16A16_SFloat;
2519
2519
  }
2520
2520
  };
2521
2521
  return KTX2Loader;
@@ -2536,7 +2536,7 @@ exports.KTX2Loader._priorityFormats = (_obj$2 = {}, _obj$2[ColorModel.ETC1S] = [
2536
2536
  ], _obj$2[ColorModel.UASTC_HDR_4X4] = [
2537
2537
  KTX2TargetFormat.ASTC_HDR_4x4,
2538
2538
  KTX2TargetFormat.BC6H,
2539
- KTX2TargetFormat.R16G16B16A16
2539
+ KTX2TargetFormat.R16G16B16A16_SFloat
2540
2540
  ], _obj$2);
2541
2541
  var _obj1$1, _obj2, _obj3, _obj4, _obj5, _obj6, _obj7, _obj8;
2542
2542
  exports.KTX2Loader._capabilityMap = (_obj8 = {}, _obj8[KTX2TargetFormat.ASTC] = (_obj1$1 = {}, _obj1$1[DFDTransferFunction.linear] = engineCore.GLCapabilityType.astc, _obj1$1[DFDTransferFunction.sRGB] = engineCore.GLCapabilityType.astc, _obj1$1), _obj8[KTX2TargetFormat.ETC] = (_obj2 = {}, _obj2[DFDTransferFunction.linear] = engineCore.GLCapabilityType.etc, _obj2[DFDTransferFunction.sRGB] = engineCore.GLCapabilityType.etc, _obj2), _obj8[KTX2TargetFormat.BC7] = (_obj3 = {}, _obj3[DFDTransferFunction.linear] = engineCore.GLCapabilityType.bptc, _obj3[DFDTransferFunction.sRGB] = engineCore.GLCapabilityType.bptc, _obj3), _obj8[KTX2TargetFormat.BC1_BC3] = (_obj4 = {}, _obj4[DFDTransferFunction.linear] = engineCore.GLCapabilityType.s3tc, _obj4[DFDTransferFunction.sRGB] = engineCore.GLCapabilityType.s3tc_srgb, _obj4), _obj8[KTX2TargetFormat.BC6H] = (_obj5 = {}, _obj5[DFDTransferFunction.linear] = engineCore.GLCapabilityType.bptc, _obj5), _obj8[KTX2TargetFormat.ASTC_HDR_4x4] = (_obj6 = {}, _obj6[DFDTransferFunction.linear] = engineCore.GLCapabilityType.astc_hdr, _obj6), _obj8[KTX2TargetFormat.PVRTC] = (_obj7 = {}, _obj7[DFDTransferFunction.linear] = engineCore.GLCapabilityType.pvrtc, _obj7), _obj8);
@@ -2610,7 +2610,7 @@ var AmbientLightLoader = /*#__PURE__*/ function(Loader) {
2610
2610
  });
2611
2611
  } else {
2612
2612
  var size = new Uint16Array(buffer, textureOffset, 1)[0];
2613
- texture || (texture = new engineCore.TextureCube(engine, size, engineCore.TextureFormat.R16G16B16A16, true, false));
2613
+ texture || (texture = new engineCore.TextureCube(engine, size, engineCore.TextureFormat.R16G16B16A16_SFloat, true, false));
2614
2614
  texture.filterMode = engineCore.TextureFilterMode.Trilinear;
2615
2615
  var mipmapCount = texture.mipmapCount;
2616
2616
  var offset = textureOffset + 2;
@@ -5037,7 +5037,7 @@ exports.GLTFTextureParser = /*#__PURE__*/ function(GLTFParser1) {
5037
5037
  var imageBuffer = new Uint8Array(buffer, (_bufferView_byteOffset = bufferView.byteOffset) != null ? _bufferView_byteOffset : 0, bufferView.byteLength);
5038
5038
  return ImageDecoder._decode(imageBuffer, imageName || textureName || url, mimeType).then(function(image) {
5039
5039
  var width = image.width, height = image.height;
5040
- var format = engineCore.TextureFormat.R8G8B8A8;
5040
+ var format = engineCore.TextureFormat.R8G8B8A8_UNorm;
5041
5041
  var _samplerInfo_mipmap;
5042
5042
  var generateMipmap = engineCore.TextureUtils.supportGenerateMipmapsWithCorrection(format, (_samplerInfo_mipmap = samplerInfo == null ? void 0 : samplerInfo.mipmap) != null ? _samplerInfo_mipmap : true, isSRGBColorSpace);
5043
5043
  var texture = new engineCore.Texture2D(engine, width, height, format, generateMipmap, isSRGBColorSpace);
@@ -6105,14 +6105,14 @@ var TextureLoader = /*#__PURE__*/ function(Loader) {
6105
6105
  var _this = this;
6106
6106
  return new engineCore.AssetPromise(function(resolve, reject) {
6107
6107
  var engine = resourceManager.engine;
6108
- if (!engineCore.SystemInfo.supportsTextureFormat(engine, engineCore.TextureFormat.R16G16B16A16)) {
6108
+ if (!engineCore.SystemInfo.supportsTextureFormat(engine, engineCore.TextureFormat.R16G16B16A16_SFloat)) {
6109
6109
  reject(new Error("TextureLoader: HDR texture requires half float support."));
6110
6110
  return;
6111
6111
  }
6112
6112
  var _HDRDecoder_decode = HDRDecoder.decode(buffer), width = _HDRDecoder_decode.width, height = _HDRDecoder_decode.height, pixels = _HDRDecoder_decode.pixels;
6113
6113
  var _item_params;
6114
6114
  var _ref = (_item_params = item.params) != null ? _item_params : {}, _ref_mipmap = _ref.mipmap, mipmap = _ref_mipmap === void 0 ? true : _ref_mipmap;
6115
- var texture = new engineCore.Texture2D(engine, width, height, engineCore.TextureFormat.R16G16B16A16, mipmap, false);
6115
+ var texture = new engineCore.Texture2D(engine, width, height, engineCore.TextureFormat.R16G16B16A16_SFloat, mipmap, false);
6116
6116
  texture.setPixelBuffer(pixels);
6117
6117
  mipmap && texture.generateMipmaps();
6118
6118
  _this._applyParams(texture, item);
@@ -6123,7 +6123,7 @@ var TextureLoader = /*#__PURE__*/ function(Loader) {
6123
6123
  var _this = this;
6124
6124
  return ImageDecoder._decode(buffer, item.url).then(function(img) {
6125
6125
  var _item_params;
6126
- var _ref = (_item_params = item.params) != null ? _item_params : {}, _ref_format = _ref.format, format = _ref_format === void 0 ? engineCore.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;
6126
+ var _ref = (_item_params = item.params) != null ? _item_params : {}, _ref_format = _ref.format, format = _ref_format === void 0 ? engineCore.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;
6127
6127
  var engine = resourceManager.engine;
6128
6128
  var width = img.width, height = img.height;
6129
6129
  var generateMipmap = engineCore.TextureUtils.supportGenerateMipmapsWithCorrection(format, mipmap, isSRGBColorSpace);
@@ -6326,7 +6326,7 @@ var RenderTargetLoader = /*#__PURE__*/ function(Loader) {
6326
6326
  var _props_mipmap;
6327
6327
  var mipmap = (_props_mipmap = props == null ? void 0 : props.mipmap) != null ? _props_mipmap : true;
6328
6328
  var _props_isSRGBColorSpace;
6329
- var isSRGB = (_props_isSRGBColorSpace = props == null ? void 0 : props.isSRGBColorSpace) != null ? _props_isSRGBColorSpace : format === engineCore.TextureFormat.R8G8B8A8;
6329
+ var isSRGB = (_props_isSRGBColorSpace = props == null ? void 0 : props.isSRGBColorSpace) != null ? _props_isSRGBColorSpace : format === engineCore.TextureFormat.R8G8B8A8_UNorm;
6330
6330
  var texture = new engineCore.Texture2D(engine, width, height, format, mipmap, isSRGB);
6331
6331
  if (props) {
6332
6332
  if (props.filterMode != null) texture.filterMode = props.filterMode;