@galacean/engine-loader 2.0.0-alpha.33 → 2.0.0-alpha.35
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 +22 -43
- package/dist/main.js.map +1 -1
- package/dist/module.js +23 -44
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/gltf/parser/GLTFSceneParser.d.ts +1 -1
- package/types/gltf/parser/GLTFSkinParser.d.ts +4 -0
package/dist/main.js
CHANGED
|
@@ -3318,13 +3318,13 @@ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
|
3318
3318
|
_this.needAnimatorController = !!(json.skins || json.animations);
|
|
3319
3319
|
return engineCore.AssetPromise.all([
|
|
3320
3320
|
_this.get(1),
|
|
3321
|
+
_this.get(2),
|
|
3321
3322
|
_this.get(5),
|
|
3322
3323
|
_this.get(6),
|
|
3323
3324
|
_this.get(7),
|
|
3324
3325
|
_this.get(9),
|
|
3325
3326
|
_this.get(10),
|
|
3326
|
-
_this.get(11)
|
|
3327
|
-
_this.get(2)
|
|
3327
|
+
_this.get(11)
|
|
3328
3328
|
]).then(function() {
|
|
3329
3329
|
var glTFResource = _this.glTFResource;
|
|
3330
3330
|
var animatorController = glTFResource.animatorController;
|
|
@@ -4974,35 +4974,15 @@ exports.GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
4974
4974
|
if (rootBoneIndex !== -1) {
|
|
4975
4975
|
engineMath.BoundingBox.transform(mesh.bounds, inverseBindMatrices[rootBoneIndex], skinnedMeshRenderer.localBounds);
|
|
4976
4976
|
} else {
|
|
4977
|
-
//
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
if (subRootBoneCount !== 0) {
|
|
4982
|
-
engineMath.Matrix.multiplyScalar(approximateBindMatrix, 1.0 / subRootBoneCount, approximateBindMatrix);
|
|
4983
|
-
engineMath.BoundingBox.transform(mesh.bounds, approximateBindMatrix, skinnedMeshRenderer.localBounds);
|
|
4984
|
-
} else {
|
|
4985
|
-
skinnedMeshRenderer.localBounds.copyFrom(mesh.bounds);
|
|
4986
|
-
}
|
|
4987
|
-
}
|
|
4988
|
-
};
|
|
4989
|
-
_proto._computeApproximateBindMatrix = function _computeApproximateBindMatrix(jointEntities, inverseBindMatrices, rootEntity, approximateBindMatrix) {
|
|
4990
|
-
var subRootBoneCount = 0;
|
|
4991
|
-
var children = rootEntity.children;
|
|
4992
|
-
for(var i = 0, n = children.length; i < n; i++){
|
|
4993
|
-
var rootChild = children[i];
|
|
4994
|
-
var index = jointEntities.indexOf(rootChild);
|
|
4995
|
-
if (index !== -1) {
|
|
4996
|
-
engineMath.Matrix.add(approximateBindMatrix, inverseBindMatrices[index], approximateBindMatrix);
|
|
4997
|
-
subRootBoneCount++;
|
|
4998
|
-
} else {
|
|
4999
|
-
subRootBoneCount += this._computeApproximateBindMatrix(jointEntities, inverseBindMatrices, rootChild, approximateBindMatrix);
|
|
5000
|
-
}
|
|
4977
|
+
// rootBone can be outside skin.joints, so it has no inverse bind matrix
|
|
4978
|
+
var inverseRootBoneWorld = GLTFSceneParser._tempMatrix;
|
|
4979
|
+
engineMath.Matrix.invert(rootBone.transform.worldMatrix, inverseRootBoneWorld);
|
|
4980
|
+
engineMath.BoundingBox.transform(mesh.bounds, inverseRootBoneWorld, skinnedMeshRenderer.localBounds);
|
|
5001
4981
|
}
|
|
5002
|
-
return subRootBoneCount;
|
|
5003
4982
|
};
|
|
5004
4983
|
return GLTFSceneParser;
|
|
5005
4984
|
}(GLTFParser);
|
|
4985
|
+
exports.GLTFSceneParser._tempMatrix = new engineMath.Matrix();
|
|
5006
4986
|
exports.GLTFSceneParser = __decorate([
|
|
5007
4987
|
registerGLTFParser(GLTFParserType.Scene)
|
|
5008
4988
|
], exports.GLTFSceneParser);
|
|
@@ -5037,23 +5017,29 @@ exports.GLTFSkinParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
5037
5017
|
skin.joints[i] = bone.name;
|
|
5038
5018
|
}
|
|
5039
5019
|
skin.bones = bones;
|
|
5040
|
-
// Get skeleton
|
|
5020
|
+
// Get skeleton — when `skin.skeleton` is absent, resolve via joints' LCA
|
|
5021
|
+
// LCA falls back to the GLTF_ROOT wrapper only when joints span multiple top-level scene nodes
|
|
5041
5022
|
if (skeleton !== undefined) {
|
|
5042
5023
|
var rootBone = entities[skeleton];
|
|
5024
|
+
if (!rootBone) {
|
|
5025
|
+
throw "Skin skeleton index " + skeleton + " is out of range.";
|
|
5026
|
+
}
|
|
5043
5027
|
skin.rootBone = rootBone;
|
|
5044
5028
|
} else {
|
|
5045
5029
|
var rootBone1 = _this._findSkeletonRootBone(joints, entities);
|
|
5046
|
-
if (rootBone1) {
|
|
5047
|
-
skin.rootBone = rootBone1;
|
|
5048
|
-
} else {
|
|
5030
|
+
if (!rootBone1) {
|
|
5049
5031
|
throw "Failed to find skeleton root bone.";
|
|
5050
5032
|
}
|
|
5033
|
+
skin.rootBone = rootBone1;
|
|
5051
5034
|
}
|
|
5052
5035
|
return skin;
|
|
5053
5036
|
});
|
|
5054
5037
|
return engineCore.AssetPromise.resolve(skinPromise);
|
|
5055
5038
|
};
|
|
5056
|
-
|
|
5039
|
+
/**
|
|
5040
|
+
* Resolve the skeleton rootBone as the lowest common ancestor of the joints' parent chains.
|
|
5041
|
+
* Returns null when joints share no common ancestor.
|
|
5042
|
+
*/ _proto._findSkeletonRootBone = function _findSkeletonRootBone(joints, entities) {
|
|
5057
5043
|
var paths = {};
|
|
5058
5044
|
for(var _iterator = _create_for_of_iterator_helper_loose(joints), _step; !(_step = _iterator()).done;){
|
|
5059
5045
|
var index = _step.value;
|
|
@@ -6325,7 +6311,10 @@ AudioLoader = __decorate([
|
|
|
6325
6311
|
engineCore.resourceLoader(engineCore.AssetType.Audio, [
|
|
6326
6312
|
"mp3",
|
|
6327
6313
|
"ogg",
|
|
6328
|
-
"wav"
|
|
6314
|
+
"wav",
|
|
6315
|
+
"m4a",
|
|
6316
|
+
"aac",
|
|
6317
|
+
"flac"
|
|
6329
6318
|
])
|
|
6330
6319
|
], AudioLoader);
|
|
6331
6320
|
|
|
@@ -6336,7 +6325,6 @@ var ShaderLoader = /*#__PURE__*/ function(Loader) {
|
|
|
6336
6325
|
}
|
|
6337
6326
|
var _proto = ShaderLoader.prototype;
|
|
6338
6327
|
_proto.load = function load(item, resourceManager) {
|
|
6339
|
-
var _this = this;
|
|
6340
6328
|
var url = item.url;
|
|
6341
6329
|
if (url.endsWith(".shaderc")) {
|
|
6342
6330
|
// @ts-ignore
|
|
@@ -6351,20 +6339,11 @@ var ShaderLoader = /*#__PURE__*/ function(Loader) {
|
|
|
6351
6339
|
return resourceManager._request(url, _extends({}, item, {
|
|
6352
6340
|
type: "text"
|
|
6353
6341
|
})).then(function(code) {
|
|
6354
|
-
var builtinShader = _this._getBuiltinShader(code);
|
|
6355
|
-
if (builtinShader) {
|
|
6356
|
-
return engineCore.Shader.find(builtinShader);
|
|
6357
|
-
}
|
|
6358
6342
|
return engineCore.Shader.create(code, undefined, url);
|
|
6359
6343
|
});
|
|
6360
6344
|
};
|
|
6361
|
-
_proto._getBuiltinShader = function _getBuiltinShader(code) {
|
|
6362
|
-
var match = code.match(ShaderLoader._builtinRegex);
|
|
6363
|
-
if (match && match[1]) return match[1];
|
|
6364
|
-
};
|
|
6365
6345
|
return ShaderLoader;
|
|
6366
6346
|
}(engineCore.Loader);
|
|
6367
|
-
ShaderLoader._builtinRegex = /^\s*\/\/\s*@builtin\s+(\w+)/;
|
|
6368
6347
|
ShaderLoader = __decorate([
|
|
6369
6348
|
engineCore.resourceLoader(engineCore.AssetType.Shader, [
|
|
6370
6349
|
"shader",
|