使用A-Frame运行简单的OBJ文件时出现问题

吉列尔梅·马克(Guilherme Marques)

您好,我正在尝试使用A-Frame库运行在Blender上渲染的简单OBJ文件,但是结果中充满了bug。这就是我正在使用的代码,您可以看到这是一个非常简单的代码:

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<script type="text/javascript" src="javascripts/aframe.min.js"></script>
	<script type="text/javascript" src="javascripts/aframe-extras.min.js"></script>

	<title></title>
</head>
<body>
	<a-scene inspector="url: javascripts/aframe-inspector.min.js">
		<a-assets>
			<!-- 3d models -->
			<!-- <a-asset-item id="ead-obj" src="models/Objetos/ead.obj"></a-asset-item>
			<a-asset-item id="ead-mtl" src="models/Objetos/ead.mtl"></a-asset-item> -->

			<a-asset-item id="predio-obj" src="models/Teste/campus2.obj"></a-asset-item> 
			<a-asset-item id="predio-mtl" src="models/Teste/campus2.mtl"></a-asset-item> <- Here I set the items and the path.

			<!-- <a-asset-item id="sala01-obj" src="models/Objetos/sala01.obj"></a-asset-item>
			<a-asset-item id="sala01-mtl" src="models/Objetos/sala01.mtl"></a-asset-item>

			<a-asset-item id="sala02-obj" src="models/Objetos/sala02.obj"></a-asset-item>
			<a-asset-item id="sala02-mtl" src="models/Objetos/sala02.mtl"></a-asset-item> -->

			<!-- checkpoint -->
			<a-mixin id="checkpoint"></a-mixin>
        	<a-mixin id="checkpoint-hovered" color="#6CEEB5"></a-mixin>
		</a-assets>

		<a-camera 
				position="0 10 25"
				camera="userHeight: 16"
               	universal-controls="movementControls: checkpoint"
                checkpoint-controls="mode: animate; animateSpeed: 40">
			<a-cursor></a-cursor>
		</a-camera>

		<a-entity>

			<a-entity
				id="Predio"
				position = "10 20 0"
				obj-model="obj: #predio-obj; mtl: #predio-mtl"
				checkpoint="offset: -15 6 15"
				scale = "3 3 3"
				>
			</a-entity> <- and here I put the entity as is recommended on A-frame.

			<a-entity
				id="Ead"
				position = "10.5 20 0"
				obj-model="obj: #ead-obj; mtl: #ead-mtl"
				checkpoint="offset: -24 5 10"
				scale = "3 3 3"
				>
			</a-entity>

	<!--	<a-entity
				id="Build"
				position = "18 20 0"
				obj-model="obj: #sala01-obj; mtl: #sala01-mtl"
				checkpoint="offset: 0 10 20"
				scale = "3 3 3"
				>
			</a-entity> -->

			<a-entity
				id="Sala02"
				position = "25 20 0"
				obj-model="obj: #sala02-obj; mtl: #sala02-mtl"
				checkpoint="offset: 15 5 15"
				scale = "3 3 3"
				>
			</a-entity>
		</a-entity>	

		<a-sky color="lightblue"></a-sky>	
	</a-scene>
</body>
</html>

所以我运行这段代码,它显示的是这样的:

这是错误的结果:

图片

这是一个只有4MB的小文件。

皮特·亚当·米勒夫斯基

我建议使用glTF格式。a-frame小组在docs中也建议使用它是专门为webGL引擎制作的。

出口商是一个简单的搅拌机插件,如果你想在你的模型动画尝试这一个

至于obj / mtl组合-mtl文件很少起作用,并且material不能保证在.obj上使用组件,正如a-frame的Don McCurdy在此处指出的那样,他还建议使用glTF格式。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章