arjs不显示gltf模型

问题描述

我正在尝试根据网站上的教程,特别是this one

创建一个简单的arjs应用程序

我已经能够成功地将其他gltf模型换成新代码,但是每当我尝试使用自己的模型时,它们就不会显示在应用程序中。

我在https://gltf-viewer.donmccurdy.com/的查看器中测试了我的模型,它显示正常。

我的代码在下面。

<body style='margin : 0px; overflow: hidden;'>
    <!-- we add detectionMode and matrixCodeType to tell AR.js to recognize barcode markers -->
    <a-scene embedded vr-mode-ui="enabled: false" arjs="sourceType: webcam; debugUIEnabled: false; detectionMode: mono_and_matrix; matrixCodeType: 3x3;">

    <a-assets>
        <a-asset-item id="animated-asset" src="https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Duck/glTF/Duck.gltf"></a-asset-item>
        <a-asset-item id="bimmer" src="https://raw.githubusercontent.com/jaggre/consortium/master/compresso.gltf"></a-asset-item>
    </a-assets>

    <a-marker type='barcode' value='2'>
        <a-entity 
        animation-mixer
        gltf-model="#bimmer"
        scale="4 4 4">
    </a-marker>

    <a-marker id="animated-marker" type='barcode' value='6'>
        <a-entity
            animation-mixer
            gltf-model="#animated-asset"
            scale="2 2 2">
        </a-entity>
    </a-marker>

    <a-entity camera></a-entity>
    </a-scene>
</body>

解决方法

在控制台中检查是否存在跨源资源共享错误-有时,如果您的网站是通过http托管的,或者以其他方式设置的,则无法正常工作。参见https://aframe.io/docs/1.0.0/core/asset-management-system.html#cross-origin-resource-sharing-corshttps://aframe.io/docs/1.0.0/introduction/installation.html#use-a-local-server。如果您仅在测试时使用file://协议,则可能无法正常工作。

您可以尝试的其他方法是将模型的a-entity标签移到marker标签之外,以查看marker类是否对它有影响。也许检查一下A框架检查器(按Ctrl Alt I),然后四处看看是否显示在错误的位置。

更新:gltf2.0 not showing in ar.js project似乎是一个类似的问题。也许也尝试一下答案。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...