blender - Aframe 中使用 gltf-part 导入的场景将对象原点重置为 0,0,0

标签 blender aframe gltf

问题:与 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 时,原点仍然位于立方体的中心。

Blender file origin of top right cube is in center, even after export to gltf and imported again Aframes inspector shows origin of all cubes and selected top right cube is 0,0,0

如果 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/

相关文章:

three.js - 我可以在 gltf 模型上放置 THREE.js Material 吗?

javascript - (A-Frame) 本地 gltf 不会加载;无法读取未定义的属性 'slice'

python - Blender,使用提示命令将 .STL 转换为 .obj

python - 在 Blender 中无线读取数据时运行游戏引擎

python - 我对 Blender 中的 Python 脚本有一个严重的问题

three.js - Blender2.8 gltf 导出带有凹凸贴图、法线贴图或粗糙度贴图的 Three.js?

tensorflow - 我可以在 Maya 和 Blender 中导入 tensorflow 和 keras

javascript - 在输入帧时播放视频

javascript - 带有光标鼠标射线原点的aframe嵌入式场景

javascript - a-frame 将我的 SVG 转换为像素图像