为什么我的模型无法通过A-Frame加载? [英] Why is my model not loading with A-Frame?

查看:437
本文介绍了为什么我的模型无法通过A-Frame加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在A框架中有COLLADA,OBJ / MTL等模型,其中< a-collada-model> < a -obj-model>

I have a COLLADA, OBJ/MTL, etc model in A-Frame with <a-collada-model> or <a-obj-model>.

当我将其添加到场景中时,什么也看不到。

When I add it to the scene, I don't see anything. What is going on?

推荐答案

使用网络服务器:

请确保您使用的是带有正确Mime类型的CORS的本地Web服务器或托管Web服务器。而不是尝试使用文件系统。

Make sure you are using a local webserver or hosted webserver with CORS with correct mime types. Rather than trying to use filesystem.

检查CORS

如果您从另一个域加载资产,您将需要在资产上设置跨域资源共享(CORS)标头。

If you are loading the asset from a different domain, you will need cross-origin resource sharing (CORS) headers set on the asset.

对于某些选项,所有托管在GitHub上的资源页面带有CORS标头。我们强烈建议将GitHub Pages作为简单的部署平台。

For some options, all resources hosted on GitHub Pages are served with CORS headers. We highly recommend GitHub Pages as a simple deployment platform.

或者,您也可以使用 A帧+ Uploadcare Uploader ,该服务将有助于为CORS的资产提供服务。 (当前不起作用)。

Alternatively, you could also upload assets using the A-Frame + Uploadcare Uploader, a service that will help serve our assets CORS’d. (currently not working).

要抓住的是 OBJ ,只有最新版本的A-Frame最高可达0.3.0在MTLLoader上启用了跨域,因此直到0.3.0都可能有效。不确定。

A catch to this is for OBJ, only the latest builds of A-Frame leading up to 0.3.0 enabled cross-origin on the MTLLoader, so that may or may not work until 0.3.0. Unsure.

检查规模:

模型的规模通常非常大,与相机相比非常大。它们可能比用户大1000倍,从而使用户位于模型内而看不到它。尝试将其缩小到 scale =。001 .001 .001 并查看其位置。

The scale of models are often very, very large in comparison to the camera. They might be 1000 times bigger than the user such that the user is inside the model and cannot see it. Try scaling it down scale=".001 .001 .001" and see where it is.

A -Frame Inspector附带0.3.0将对此有很大帮助。出现这种情况时,请按 ctrl + shift + i 将其打开。

The A-Frame Inspector shipping with 0.3.0 will help tremendously with this. When that comes out, press ctrl+shift+i to open it.

如果缺少纹理,请检查路径:

通常可以确定图像上是否显示404。如果使用带有单独材质文件的模型(例如MTL),则它们通常通过相对路径引用图像纹理。通过读取图像路径的MTL文件,确保图像相对于MTL文件位于正确的预期位置。并确保它们具有正确的名称。

You can usually tell if you are getting 404 on images. If using a model with separate material file such as MTL, they often refer to image textures via relative paths. Make sure that the images are in the right expected location in relation to the MTL file by reading through the MTL file for image paths. And also make sure they have the right name.

如果渲染为黑色,则将纹理转换为使用图像:

为什么我的OBJ / MTL模型材料显示为黑色?

这篇关于为什么我的模型无法通过A-Frame加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆