1.背景
学习aframe的时候想要把模型更换成自己下载或者创建的
WebXR 应用开发之 aframe 框架入门 - 知乎 (zhihu.com)
2.代码
<a-asset-item
id= weapon
src=http://192.168.0.14:9090/unicity-picture/splat/hatGltf/hat.gltf
></a-asset-item>
</a-assets>
<a-box scale= "30 20 4" position= "0 0 -10" src= #wallImg ></a-box>
<a-text
id= start-text
value= Start
color=#BBB
position= "-3 6 -18"
scale= "10 10 10"
font= mozillavr
start-focus
>
</a-text>
<a-camera>
<a-cursor color= #FAFAFA cursor-listener></a-cursor>
<a-entity
sound="src: #shooting-sound"
id="shooting_sound_player"
position="0.5 -0.5 -0.8"
poolSize="10"
></a-entity>
<a-gltf-model
id= _weapon
src= #weapon
position= "0.5 -0.5 -0.8"
scale= "1 1 1"
rotation= "0 180 0"
></a-gltf-model>
先在asset里面声明这个资产,再在后面引用
src=http://192.168.0.14:9090/unicity-picture/splat/hatGltf/hat.gltf
这里就是引用的链接了
glTF (GL Transmission Format) - Sketchfab
在这个网站下载gltf模型,
下载后的目录层次长这个样子
然后记得把整个文件夹放到你的服务器上面 ,不要只放一个hat.gltf,否则肯定没有纹理和scene
然后引用的时候,链接是/hatGltf/hat.gltf
这样AFrame就可以加载你的gltf模型了