我正在尝试根据网站上的教程,特别是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>
答案 0 :(得分:0)
在控制台中检查是否存在跨源资源共享错误-有时,如果您的网站是通过http托管的,或者以其他方式设置的,则无法正常工作。参见https://aframe.io/docs/1.0.0/core/asset-management-system.html#cross-origin-resource-sharing-cors和https://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似乎是一个类似的问题。也许也尝试一下答案。