问题:与 gltf-part 一起使用的对象的起源位于 0,0,0
codesandbox 示例:https://codesandbox.io/s/xenodochial-moore-4383f?file=/index.html
shows a log with the correct positions when displayed as a scene and one where I use gltf-part to show the cubes where all positions of the cubes are at 0,0,0
导出的场景来自 blender ,其中我将原点设置为每个立方体的中心,请参见右上角的立方体。
在 Aframe 中导入 gltf 文件,并用 gltf-part 显示立方体后,每个立方体的原点都是 0,0,0。
GLTF 是正确的,当我再次将其导入 blender 时,原点仍然位于立方体的中心。
如果 Aframe 中每个立方体都位于位置 0,0,0,如何获得它们的正确坐标?
最佳答案
这对我有用:
window.addEventListener("model-loaded", (e) => {
const sceneObj = document.querySelector("a-scene").object3D;
let object;
object = sceneObj.getObjectByProperty("name", "cube1");
console.log(object.position);
object = sceneObj.getObjectByProperty("name", "cube2");
console.log(object.position);
});
关于blender - Aframe 中使用 gltf-part 导入的场景将对象原点重置为 0,0,0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61840351/