首页 > 解决方案 > AR.js 和 aframe 管理我的 .gltf 位置和尺寸

问题描述

我是 ar.js 和 Aframe 的新手,我在一个 gltf 对象的 hito 模式上编写了一个简单的代码表单 displat:

<!-- include A-Frame obviously -->
<script src="https://aframe.io/releases/1.0.4/aframe.min.js"></script>
<!-- include ar.js for A-Frame -->
<script src="https://jeromeetienne.github.io/AR.js/aframe/build/aframe-ar.js"></script>

<body style='margin : 0px; overflow: hidden;'>
  <a-scene embedded arjs>
    <!-- define your gltf asset -->
    <a-assets>
      <a-asset-item id="tree" src="models/gltf/manovella.gltf"></a-asset-item>
    </a-assets>
    <a-entity gltf-model="#tree"></a-entity>
    <!-- define a camera which will move according to the marker position -->
    <a-marker-camera preset='hiro'></a-marker-camera>
  </a-scene>
</body>

所有作品都在用餐,我的对象变得可见,但太小且位置错误:

在此处输入图像描述

我尝试在 aframe 文档中搜索有关 a-asset-item 的信息,但找不到有关位置尺寸和旋转的 anityng。

有人可以帮助我了解如何管理我的对象的外观?

非常感谢提前

标签: three.jsaframear.js

解决方案


A-Frame 中的所有 <a-entity> 元素都有positionrotationscale组件,您可以像任何实体一样使用它们来管理您的模型。你可以像这样使用它们:

<a-entity gltf-model="#tree" position="0 3 0" rotation="0 90 0" scale="3 3 3"

如果您还没有阅读它,有很多关于 A-Frame 文档的信息,您可以从本指南开始了解基础知识。


推荐阅读