【问题标题】:Obj file becomes white when mtl is added添加mtl时obj文件变白
【发布时间】:2019-07-30 02:43:48
【问题描述】:

我正在用框架编写一个脚本来展示地球。但是,当我尝试添加纹理时,它变成了全白。

这是我的脚本:

<html>
  <head>
    <div class="navbar">

    </div>
    <!-- aframe itself -->
    <script src="//cdn.rawgit.com/donmccurdy/aframe-extras/v3.13.1/dist/aframe-extras.min.js"></script>
    <script src="https://aframe.io/releases/0.9.0/aframe.min.js"></script>
    <a-scene stats>
        <a-assets>
          <a-asset-item id="earth-obj" src="https://cdn.glitch.com/5995a6f7-2893-46f8-a015-8513de4817c6%2F1227%20Earth.obj?1551999264805"></a-asset-item>
          <a-asset-item id="earth-mtl" src="https://cdn.glitch.com/5995a6f7-2893-46f8-a015-8513de4817c6%2F1227%20Earth.mtl?1552002240966"></a-asset-item>
        </a-assets>

        <!-- Image links. -->
        <a-entity id="links" layout="type: line; margin: 1.5" position="0 -1 -4">
          <a-entity template="src: #link" data-src="#cubes" data-thumb="#cubes-thumb"></a-entity>
          <a-entity template="src: #link" data-src="#city" data-thumb="#city-thumb"></a-entity>
          <a-entity template="src: #link" data-src="#sechelt" data-thumb="#sechelt-thumb"></a-entity>
        </a-entity>
        <a-entity obj-model="obj: #earth-obj; mtl: #earth-mtl" 
                  position="0 1.5 -3"
                  scale="0.05 0.05 0.05">
          <a-animation attribute="rotation"
                       dur="30"
                       to="0 360 0"
                       repeat="indefinite"
                       easing="linear"></a-animation>
        </a-entity>
        <a-entity camera look-controls position="0 1.5 0">
            <a-cursor>
              <a-entity position="0 0 -3" id="weapon">
                <a-box color="blue" width="0.25" height="0.5" depth="3"
                       static-body></a-box>
              </a-entity>
            </a-cursor>
        </a-entity>
      <a-entity environment="shadow: true; shadowSize: 10; preset:default;" ></a-entity>

        <a-plane color="brown" rotation="-90 0 0" 
                 static-body
                 width="100" height="100"></a-plane>

    </a-scene>

  </head>
  <body>
  </body>
</html>

这是 .mtl 文件

newmtl Mat
    map_Kd Earth.png
usemtl Mat

Earth.png 和 .obj 和 .mtl 文件在同一目录下,我不知道该怎么办。

【问题讨论】:

    标签: aframe virtual-reality .obj


    【解决方案1】:

    您的 MTL 和纹理不在同一个目录中。它们托管在 CDN 上的各个 URL 上。 Glitch 可能会给你一种他们在同一个目录中的错觉。

    【讨论】:

    • 非常感谢!你觉得我应该怎么做?另外,非常感谢你制作这个,A-Frame 很棒。
    • 是的,只是将它托管在某个地方,或者本地项目,同一个目录。
    猜你喜欢
    • 2017-07-17
    • 2020-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-20
    • 1970-01-01
    • 2013-08-08
    • 1970-01-01
    相关资源
    最近更新 更多