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

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
@@ -293,7 +293,7 @@ exports.MeshDecoder = /*#__PURE__*/ function() {
293
293
  var encodedMeshData = JSON.parse(jsonDataString);
294
294
  // @ts-ignore Vector3 is not compatible with {x: number, y: number, z: number}.
295
295
  encodedMeshData.bounds && modelMesh.bounds.copyFrom(encodedMeshData.bounds);
296
- var offset = Math.ceil(bufferReader.offset / 4) * 4;
296
+ var offset = Math.ceil(bufferReader.position / 4) * 4;
297
297
  var buffer = bufferReader.data.buffer;
298
298
  var byteOffset = bufferReader.data.byteOffset;
299
299
  var float32Array = new Float32Array(buffer, encodedMeshData.positions.start + offset + byteOffset, (encodedMeshData.positions.end - encodedMeshData.positions.start) / 4);
@@ -2247,7 +2247,7 @@ var SupercompressionScheme;
2247
2247
  alphaSliceByteLength: sgdReader.nextUint32()
2248
2248
  };
2249
2249
  }
2250
- var endpointsByteOffset = sgdByteOffset + sgdReader.offset;
2250
+ var endpointsByteOffset = sgdByteOffset + sgdReader.position;
2251
2251
  var selectorsByteOffset = endpointsByteOffset + endpointsByteLength;
2252
2252
  var tablesByteOffset = selectorsByteOffset + selectorsByteLength;
2253
2253
  var extendedByteOffset = tablesByteOffset + tablesByteLength;
@@ -2907,6 +2907,7 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
2907
2907
  _proto.initialize = function initialize(engine, configuration) {
2908
2908
  if (configuration.ktx2Loader) {
2909
2909
  var options = configuration.ktx2Loader;
2910
+ if (options.priorityFormats) exports.KTX2Loader._priorityFormats = options.priorityFormats;
2910
2911
  if (this._isKhronosSupported(options.priorityFormats, engine) && options.workerCount !== 0) {
2911
2912
  return exports.KTX2Loader._getKhronosTranscoder(options.workerCount).init();
2912
2913
  } else {
@@ -2927,25 +2928,7 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
2927
2928
  });
2928
2929
  };
2929
2930
  _proto._isKhronosSupported = function _isKhronosSupported(priorityFormats, engine) {
2930
- if (priorityFormats === void 0) priorityFormats = [
2931
- exports.KTX2TargetFormat.ASTC,
2932
- exports.KTX2TargetFormat.ETC,
2933
- exports.KTX2TargetFormat.BC7,
2934
- exports.KTX2TargetFormat.BC1_BC3,
2935
- exports.KTX2TargetFormat.PVRTC,
2936
- exports.KTX2TargetFormat.R8G8B8A8
2937
- ];
2938
- var supportedList = new Array();
2939
- if (Array.isArray(priorityFormats[0])) {
2940
- for(var i = 0; i < priorityFormats.length; i++){
2941
- supportedList.push(exports.KTX2Loader._detectSupportedFormat(engine._hardwareRenderer, priorityFormats[i]));
2942
- }
2943
- } else {
2944
- supportedList.push(exports.KTX2Loader._detectSupportedFormat(engine._hardwareRenderer, priorityFormats));
2945
- }
2946
- return supportedList.every(function(format) {
2947
- return KhronosTranscoder.transcoderMap[format];
2948
- });
2931
+ return !!KhronosTranscoder.transcoderMap[exports.KTX2Loader._detectSupportedFormat(engine._hardwareRenderer, priorityFormats)];
2949
2932
  };
2950
2933
  /**
2951
2934
  * Destroy ktx2 transcoder worker.
@@ -2959,7 +2942,8 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
2959
2942
  /** @internal */ KTX2Loader1._parseBuffer = function _parseBuffer(buffer, engine, params) {
2960
2943
  var _params;
2961
2944
  var ktx2Container = new KTX2Container(buffer);
2962
- var formatPriorities = (_params = params) == null ? void 0 : _params.priorityFormats;
2945
+ var _params_priorityFormats;
2946
+ var formatPriorities = (_params_priorityFormats = (_params = params) == null ? void 0 : _params.priorityFormats) != null ? _params_priorityFormats : exports.KTX2Loader._priorityFormats;
2963
2947
  var targetFormat = exports.KTX2Loader._decideTargetFormat(engine, ktx2Container, formatPriorities);
2964
2948
  var transcodeResultPromise;
2965
2949
  if (exports.KTX2Loader._isBinomialInit || !KhronosTranscoder.transcoderMap[targetFormat] || !ktx2Container.isUASTC) {
@@ -3026,18 +3010,22 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
3026
3010
  return targetFormat;
3027
3011
  };
3028
3012
  KTX2Loader1._detectSupportedFormat = function _detectSupportedFormat(renderer, priorityFormats) {
3029
- if (priorityFormats === void 0) priorityFormats = [
3030
- exports.KTX2TargetFormat.ASTC,
3031
- exports.KTX2TargetFormat.ETC,
3032
- exports.KTX2TargetFormat.BC7,
3033
- exports.KTX2TargetFormat.BC1_BC3,
3034
- exports.KTX2TargetFormat.PVRTC
3035
- ];
3036
3013
  for(var i = 0; i < priorityFormats.length; i++){
3037
- var capabilities = this._supportedMap[priorityFormats[i]];
3038
- for(var j = 0; j < capabilities.length; j++){
3039
- if (renderer.canIUse(capabilities[j])) {
3040
- return priorityFormats[i];
3014
+ var format = priorityFormats[i];
3015
+ var capabilities = this._supportedMap[format];
3016
+ if (capabilities) {
3017
+ for(var j = 0; j < capabilities.length; j++){
3018
+ if (renderer.canIUse(capabilities[j])) {
3019
+ return format;
3020
+ }
3021
+ }
3022
+ } else {
3023
+ switch(priorityFormats[i]){
3024
+ case exports.KTX2TargetFormat.R8G8B8A8:
3025
+ return format;
3026
+ case exports.KTX2TargetFormat.R8:
3027
+ case exports.KTX2TargetFormat.R8G8:
3028
+ if (renderer.isWebGL2) return format;
3041
3029
  }
3042
3030
  }
3043
3031
  }
@@ -3074,6 +3062,14 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
3074
3062
  return KTX2Loader1;
3075
3063
  }(engineCore.Loader), function() {
3076
3064
  _KTX2Loader._isBinomialInit = false;
3065
+ }(), function() {
3066
+ _KTX2Loader._priorityFormats = [
3067
+ exports.KTX2TargetFormat.BC7,
3068
+ exports.KTX2TargetFormat.ASTC,
3069
+ exports.KTX2TargetFormat.BC1_BC3,
3070
+ exports.KTX2TargetFormat.ETC,
3071
+ exports.KTX2TargetFormat.PVRTC
3072
+ ];
3077
3073
  }(), function() {
3078
3074
  var _obj;
3079
3075
  _KTX2Loader._supportedMap = (_obj = {}, _obj[exports.KTX2TargetFormat.ASTC] = [
@@ -3548,6 +3544,10 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3548
3544
  relativePath = relativePath === "" ? "" + entity.name : entity.name + "/" + relativePath;
3549
3545
  entity = entity.parent;
3550
3546
  }
3547
+ // If the target node is in the default scene, relativePath will be empty
3548
+ if (entity !== context.glTFResource.defaultSceneRoot) {
3549
+ continue;
3550
+ }
3551
3551
  var ComponentType = void 0;
3552
3552
  var propertyName = void 0;
3553
3553
  switch(target.path){