@galacean/engine-loader 1.1.0-beta.13 → 1.1.0-beta.14

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.
@@ -294,7 +294,7 @@ exports.MeshDecoder = /*#__PURE__*/ function() {
294
294
  var encodedMeshData = JSON.parse(jsonDataString);
295
295
  // @ts-ignore Vector3 is not compatible with {x: number, y: number, z: number}.
296
296
  encodedMeshData.bounds && modelMesh.bounds.copyFrom(encodedMeshData.bounds);
297
- var offset = Math.ceil(bufferReader.offset / 4) * 4;
297
+ var offset = Math.ceil(bufferReader.position / 4) * 4;
298
298
  var buffer = bufferReader.data.buffer;
299
299
  var byteOffset = bufferReader.data.byteOffset;
300
300
  var float32Array = new Float32Array(buffer, encodedMeshData.positions.start + offset + byteOffset, (encodedMeshData.positions.end - encodedMeshData.positions.start) / 4);
@@ -2248,7 +2248,7 @@ var SupercompressionScheme;
2248
2248
  alphaSliceByteLength: sgdReader.nextUint32()
2249
2249
  };
2250
2250
  }
2251
- var endpointsByteOffset = sgdByteOffset + sgdReader.offset;
2251
+ var endpointsByteOffset = sgdByteOffset + sgdReader.position;
2252
2252
  var selectorsByteOffset = endpointsByteOffset + endpointsByteLength;
2253
2253
  var tablesByteOffset = selectorsByteOffset + selectorsByteLength;
2254
2254
  var extendedByteOffset = tablesByteOffset + tablesByteLength;
@@ -2908,6 +2908,7 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
2908
2908
  _proto.initialize = function initialize(engine, configuration) {
2909
2909
  if (configuration.ktx2Loader) {
2910
2910
  var options = configuration.ktx2Loader;
2911
+ if (options.priorityFormats) exports.KTX2Loader._priorityFormats = options.priorityFormats;
2911
2912
  if (this._isKhronosSupported(options.priorityFormats, engine) && options.workerCount !== 0) {
2912
2913
  return exports.KTX2Loader._getKhronosTranscoder(options.workerCount).init();
2913
2914
  } else {
@@ -2936,17 +2937,7 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
2936
2937
  exports.KTX2TargetFormat.PVRTC,
2937
2938
  exports.KTX2TargetFormat.R8G8B8A8
2938
2939
  ];
2939
- var supportedList = new Array();
2940
- if (Array.isArray(priorityFormats[0])) {
2941
- for(var i = 0; i < priorityFormats.length; i++){
2942
- supportedList.push(exports.KTX2Loader._detectSupportedFormat(engine._hardwareRenderer, priorityFormats[i]));
2943
- }
2944
- } else {
2945
- supportedList.push(exports.KTX2Loader._detectSupportedFormat(engine._hardwareRenderer, priorityFormats));
2946
- }
2947
- return supportedList.every(function(format) {
2948
- return KhronosTranscoder.transcoderMap[format];
2949
- });
2940
+ return !!KhronosTranscoder.transcoderMap[exports.KTX2Loader._detectSupportedFormat(engine._hardwareRenderer, priorityFormats)];
2950
2941
  };
2951
2942
  /**
2952
2943
  * Destroy ktx2 transcoder worker.
@@ -2960,7 +2951,8 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
2960
2951
  /** @internal */ KTX2Loader1._parseBuffer = function _parseBuffer(buffer, engine, params) {
2961
2952
  var _params;
2962
2953
  var ktx2Container = new KTX2Container(buffer);
2963
- var formatPriorities = (_params = params) == null ? void 0 : _params.priorityFormats;
2954
+ var _params_priorityFormats;
2955
+ var formatPriorities = (_params_priorityFormats = (_params = params) == null ? void 0 : _params.priorityFormats) != null ? _params_priorityFormats : exports.KTX2Loader._priorityFormats;
2964
2956
  var targetFormat = exports.KTX2Loader._decideTargetFormat(engine, ktx2Container, formatPriorities);
2965
2957
  var transcodeResultPromise;
2966
2958
  if (exports.KTX2Loader._isBinomialInit || !KhronosTranscoder.transcoderMap[targetFormat] || !ktx2Container.isUASTC) {
@@ -3027,13 +3019,6 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
3027
3019
  return targetFormat;
3028
3020
  };
3029
3021
  KTX2Loader1._detectSupportedFormat = function _detectSupportedFormat(renderer, priorityFormats) {
3030
- if (priorityFormats === void 0) priorityFormats = [
3031
- exports.KTX2TargetFormat.ASTC,
3032
- exports.KTX2TargetFormat.ETC,
3033
- exports.KTX2TargetFormat.BC7,
3034
- exports.KTX2TargetFormat.BC1_BC3,
3035
- exports.KTX2TargetFormat.PVRTC
3036
- ];
3037
3022
  for(var i = 0; i < priorityFormats.length; i++){
3038
3023
  var capabilities = this._supportedMap[priorityFormats[i]];
3039
3024
  for(var j = 0; j < capabilities.length; j++){
@@ -3075,6 +3060,14 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
3075
3060
  return KTX2Loader1;
3076
3061
  }(miniprogram.Loader), function() {
3077
3062
  _KTX2Loader._isBinomialInit = false;
3063
+ }(), function() {
3064
+ _KTX2Loader._priorityFormats = [
3065
+ exports.KTX2TargetFormat.BC7,
3066
+ exports.KTX2TargetFormat.ASTC,
3067
+ exports.KTX2TargetFormat.BC1_BC3,
3068
+ exports.KTX2TargetFormat.ETC,
3069
+ exports.KTX2TargetFormat.PVRTC
3070
+ ];
3078
3071
  }(), function() {
3079
3072
  var _obj;
3080
3073
  _KTX2Loader._supportedMap = (_obj = {}, _obj[exports.KTX2TargetFormat.ASTC] = [
package/dist/module.js CHANGED
@@ -289,7 +289,7 @@ var MeshDecoder = /*#__PURE__*/ function() {
289
289
  var encodedMeshData = JSON.parse(jsonDataString);
290
290
  // @ts-ignore Vector3 is not compatible with {x: number, y: number, z: number}.
291
291
  encodedMeshData.bounds && modelMesh.bounds.copyFrom(encodedMeshData.bounds);
292
- var offset = Math.ceil(bufferReader.offset / 4) * 4;
292
+ var offset = Math.ceil(bufferReader.position / 4) * 4;
293
293
  var buffer = bufferReader.data.buffer;
294
294
  var byteOffset = bufferReader.data.byteOffset;
295
295
  var float32Array = new Float32Array(buffer, encodedMeshData.positions.start + offset + byteOffset, (encodedMeshData.positions.end - encodedMeshData.positions.start) / 4);
@@ -2243,7 +2243,7 @@ var SupercompressionScheme;
2243
2243
  alphaSliceByteLength: sgdReader.nextUint32()
2244
2244
  };
2245
2245
  }
2246
- var endpointsByteOffset = sgdByteOffset + sgdReader.offset;
2246
+ var endpointsByteOffset = sgdByteOffset + sgdReader.position;
2247
2247
  var selectorsByteOffset = endpointsByteOffset + endpointsByteLength;
2248
2248
  var tablesByteOffset = selectorsByteOffset + selectorsByteLength;
2249
2249
  var extendedByteOffset = tablesByteOffset + tablesByteLength;
@@ -2903,6 +2903,7 @@ var KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
2903
2903
  _proto.initialize = function initialize(engine, configuration) {
2904
2904
  if (configuration.ktx2Loader) {
2905
2905
  var options = configuration.ktx2Loader;
2906
+ if (options.priorityFormats) KTX2Loader._priorityFormats = options.priorityFormats;
2906
2907
  if (this._isKhronosSupported(options.priorityFormats, engine) && options.workerCount !== 0) {
2907
2908
  return KTX2Loader._getKhronosTranscoder(options.workerCount).init();
2908
2909
  } else {
@@ -2931,17 +2932,7 @@ var KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
2931
2932
  KTX2TargetFormat.PVRTC,
2932
2933
  KTX2TargetFormat.R8G8B8A8
2933
2934
  ];
2934
- var supportedList = new Array();
2935
- if (Array.isArray(priorityFormats[0])) {
2936
- for(var i = 0; i < priorityFormats.length; i++){
2937
- supportedList.push(KTX2Loader._detectSupportedFormat(engine._hardwareRenderer, priorityFormats[i]));
2938
- }
2939
- } else {
2940
- supportedList.push(KTX2Loader._detectSupportedFormat(engine._hardwareRenderer, priorityFormats));
2941
- }
2942
- return supportedList.every(function(format) {
2943
- return KhronosTranscoder.transcoderMap[format];
2944
- });
2935
+ return !!KhronosTranscoder.transcoderMap[KTX2Loader._detectSupportedFormat(engine._hardwareRenderer, priorityFormats)];
2945
2936
  };
2946
2937
  /**
2947
2938
  * Destroy ktx2 transcoder worker.
@@ -2955,7 +2946,8 @@ var KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
2955
2946
  /** @internal */ KTX2Loader1._parseBuffer = function _parseBuffer(buffer, engine, params) {
2956
2947
  var _params;
2957
2948
  var ktx2Container = new KTX2Container(buffer);
2958
- var formatPriorities = (_params = params) == null ? void 0 : _params.priorityFormats;
2949
+ var _params_priorityFormats;
2950
+ var formatPriorities = (_params_priorityFormats = (_params = params) == null ? void 0 : _params.priorityFormats) != null ? _params_priorityFormats : KTX2Loader._priorityFormats;
2959
2951
  var targetFormat = KTX2Loader._decideTargetFormat(engine, ktx2Container, formatPriorities);
2960
2952
  var transcodeResultPromise;
2961
2953
  if (KTX2Loader._isBinomialInit || !KhronosTranscoder.transcoderMap[targetFormat] || !ktx2Container.isUASTC) {
@@ -3022,13 +3014,6 @@ var KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
3022
3014
  return targetFormat;
3023
3015
  };
3024
3016
  KTX2Loader1._detectSupportedFormat = function _detectSupportedFormat(renderer, priorityFormats) {
3025
- if (priorityFormats === void 0) priorityFormats = [
3026
- KTX2TargetFormat.ASTC,
3027
- KTX2TargetFormat.ETC,
3028
- KTX2TargetFormat.BC7,
3029
- KTX2TargetFormat.BC1_BC3,
3030
- KTX2TargetFormat.PVRTC
3031
- ];
3032
3017
  for(var i = 0; i < priorityFormats.length; i++){
3033
3018
  var capabilities = this._supportedMap[priorityFormats[i]];
3034
3019
  for(var j = 0; j < capabilities.length; j++){
@@ -3070,6 +3055,14 @@ var KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
3070
3055
  return KTX2Loader1;
3071
3056
  }(Loader), function() {
3072
3057
  _KTX2Loader._isBinomialInit = false;
3058
+ }(), function() {
3059
+ _KTX2Loader._priorityFormats = [
3060
+ KTX2TargetFormat.BC7,
3061
+ KTX2TargetFormat.ASTC,
3062
+ KTX2TargetFormat.BC1_BC3,
3063
+ KTX2TargetFormat.ETC,
3064
+ KTX2TargetFormat.PVRTC
3065
+ ];
3073
3066
  }(), function() {
3074
3067
  var _obj;
3075
3068
  _KTX2Loader._supportedMap = (_obj = {}, _obj[KTX2TargetFormat.ASTC] = [