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

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
@@ -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
- // Root bone is not in joints list, we can only compute approximate inverse bind matrix
4978
- // Average all root bone's children inverse bind matrix
4979
- var approximateBindMatrix = new engineMath.Matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
4980
- var subRootBoneCount = this._computeApproximateBindMatrix(bones, inverseBindMatrices, rootBone, approximateBindMatrix);
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);