@galacean/engine-loader 2.0.0-alpha.33 → 2.0.0-alpha.34

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
@@ -3314,13 +3314,13 @@ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
3314
3314
  _this.needAnimatorController = !!(json.skins || json.animations);
3315
3315
  return AssetPromise.all([
3316
3316
  _this.get(1),
3317
+ _this.get(2),
3317
3318
  _this.get(5),
3318
3319
  _this.get(6),
3319
3320
  _this.get(7),
3320
3321
  _this.get(9),
3321
3322
  _this.get(10),
3322
- _this.get(11),
3323
- _this.get(2)
3323
+ _this.get(11)
3324
3324
  ]).then(function() {
3325
3325
  var glTFResource = _this.glTFResource;
3326
3326
  var animatorController = glTFResource.animatorController;
@@ -5033,23 +5033,29 @@ var GLTFSkinParser = /*#__PURE__*/ function(GLTFParser) {
5033
5033
  skin.joints[i] = bone.name;
5034
5034
  }
5035
5035
  skin.bones = bones;
5036
- // Get skeleton
5036
+ // Get skeleton — when `skin.skeleton` is absent, resolve via joints' LCA
5037
+ // LCA falls back to the GLTF_ROOT wrapper only when joints span multiple top-level scene nodes
5037
5038
  if (skeleton !== undefined) {
5038
5039
  var rootBone = entities[skeleton];
5040
+ if (!rootBone) {
5041
+ throw "Skin skeleton index " + skeleton + " is out of range.";
5042
+ }
5039
5043
  skin.rootBone = rootBone;
5040
5044
  } else {
5041
5045
  var rootBone1 = _this._findSkeletonRootBone(joints, entities);
5042
- if (rootBone1) {
5043
- skin.rootBone = rootBone1;
5044
- } else {
5046
+ if (!rootBone1) {
5045
5047
  throw "Failed to find skeleton root bone.";
5046
5048
  }
5049
+ skin.rootBone = rootBone1;
5047
5050
  }
5048
5051
  return skin;
5049
5052
  });
5050
5053
  return AssetPromise.resolve(skinPromise);
5051
5054
  };
5052
- _proto._findSkeletonRootBone = function _findSkeletonRootBone(joints, entities) {
5055
+ /**
5056
+ * Resolve the skeleton rootBone as the lowest common ancestor of the joints' parent chains.
5057
+ * Returns null when joints share no common ancestor.
5058
+ */ _proto._findSkeletonRootBone = function _findSkeletonRootBone(joints, entities) {
5053
5059
  var paths = {};
5054
5060
  for(var _iterator = _create_for_of_iterator_helper_loose(joints), _step; !(_step = _iterator()).done;){
5055
5061
  var index = _step.value;
@@ -6321,7 +6327,10 @@ AudioLoader = __decorate([
6321
6327
  resourceLoader(AssetType.Audio, [
6322
6328
  "mp3",
6323
6329
  "ogg",
6324
- "wav"
6330
+ "wav",
6331
+ "m4a",
6332
+ "aac",
6333
+ "flac"
6325
6334
  ])
6326
6335
  ], AudioLoader);
6327
6336
 
@@ -6332,7 +6341,6 @@ var ShaderLoader = /*#__PURE__*/ function(Loader) {
6332
6341
  }
6333
6342
  var _proto = ShaderLoader.prototype;
6334
6343
  _proto.load = function load(item, resourceManager) {
6335
- var _this = this;
6336
6344
  var url = item.url;
6337
6345
  if (url.endsWith(".shaderc")) {
6338
6346
  // @ts-ignore
@@ -6347,20 +6355,11 @@ var ShaderLoader = /*#__PURE__*/ function(Loader) {
6347
6355
  return resourceManager._request(url, _extends({}, item, {
6348
6356
  type: "text"
6349
6357
  })).then(function(code) {
6350
- var builtinShader = _this._getBuiltinShader(code);
6351
- if (builtinShader) {
6352
- return Shader.find(builtinShader);
6353
- }
6354
6358
  return Shader.create(code, undefined, url);
6355
6359
  });
6356
6360
  };
6357
- _proto._getBuiltinShader = function _getBuiltinShader(code) {
6358
- var match = code.match(ShaderLoader._builtinRegex);
6359
- if (match && match[1]) return match[1];
6360
- };
6361
6361
  return ShaderLoader;
6362
6362
  }(Loader);
6363
- ShaderLoader._builtinRegex = /^\s*\/\/\s*@builtin\s+(\w+)/;
6364
6363
  ShaderLoader = __decorate([
6365
6364
  resourceLoader(AssetType.Shader, [
6366
6365
  "shader",