gltf文件未在Aframe中显示

时间:2019-12-10 13:04:22

标签: html aframe gltf

我有两个文件,一个glTF和OBJ文件。我正在使用Glitch进行开发,并将它们都上传到了我的资产文件夹。

当我读取标记时,仅显示OBJ文件。

<!DOCTYPE html>
<html>
<script src="https://aframe.io/releases/0.9.2/aframe.min.js"></script>
<script src="https://raw.githack.com/jeromeetienne/AR.js/master/aframe/build/aframe-ar.min.js"></script>
<script src="https://rawgit.com/donmccurdy/aframe-extras/master/dist/aframe-extras.loaders.min.js"></script>

<body style="margin : 0px; overflow: hidden;">
    <a-scene embedded arjs="debugUIEnabled: false;" vr-mode-ui="enabled: false" light="defaultLightsEnabled: true">
        <a-assets>
            <a-asset-item id="tree-gltf" src="https://cdn.glitch.com.....gltf"></a-asset-item>
            <a-asset-item id="db-mtl" src="https://cdn.glitch.com.....mtl"></a-asset-item>
            <a-asset-item id="db-obj" src="https://cdn.glitch.com....obj"></a-asset-item>
        </a-assets>
        <a-marker preset="kanji">
            <a-gltf-model src="#tree-gltf"></a-gltf-model>
            <a-obj-model src="#db-obj" mtl="#db-mtl" position="0 1.8 0"
                animation="property: rotation; to: 0 360 0; loop: true; dur: 6000"></a-obj-model>
        </a-marker>
        <a-entity camera></a-entity>
    </a-scene>
</body>
</html>

我的控制台没有任何错误。只是没有出现。

1 个答案:

答案 0 :(得分:3)

如果打开.gltf文件-您会发现.bin,并且纹理是用相对文件路径引用的。

故障“ assets”文件夹不是真实目录-其中的文件具有不同的路径,可能彼此之间距离很远。

尝试:

  1. 将模型转换为仅包含所有资源和依赖关系的.glb
  2. 将模型扔到路径相对的github仓库中
  3. 通过使用故障资产链接替换.gltf和纹理路径来编辑.bin文件。