如何重置模型中心点坐标,到模型中央? #37
-
导入的gltf默认模型中心点都不固定。虽然我设置了他们的position为(0,0,0),但是模型中心点位置不固定,所以放置位置都是满天飞。 |
Beta Was this translation helpful? Give feedback.
Answered by
cptbtptpbcptdtptp
Mar 27, 2024
Replies: 2 comments
-
这个是模型锚点设置的问题,有些模型局部(0,0,0)的位置不在中心点,当然你可以通过计算这个模型的包围盒,从而用包围盒的中心点让模型看起来居中,可以参考下方示例来计算模型的空间包围盒: |
Beta Was this translation helpful? Give feedback.
0 replies
-
有三种办法:
const renderers = entity.getComponentsIncludeChildren(MeshRenderer, []);
const boundingBox = renderers[0].bounds.clone();
for (let i = renderers.length - 1; i > 0; i--) {
BoundingBox.merge(boundingBox, renderers[i].bounds, boundingBox);
}
// 模型中心点
boundingBox.getCenter(new Vector3()); 建议让美术导出时指定模型中心点。 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
cptbtptpbcptdtptp
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
有三种办法:
建议让美术导出时指定模型中心点。