[英]A-Frame local image is not loading
<!doctype html>
<html>
<head>
<script src="https://rawgit.com/aframevr/aframe/b813db0614ac2b518e547105e810b5b6eccfe1c8/dist/aframe.min.js"></script>
</head>
<body>
<script>
AFRAME.registerComponent('set-sky', {
schema: {default: ''},
init() {
const sky = document.querySelector('a-sky');
this.el.addEventListener('click', () => {
sky.setAttribute('src', this.data);
});
}
});
</script>
<a-scene>
<a-camera position="0 2 4">
<a-cursor color="#4CC3D9" fuse="true" timeout="10"></a-cursor>
</a-camera>
<a-sphere color="#F44336" radius="1" position="-4 2 0" set-sky="https://c3.staticflickr.com/2/1475/26239222850_cabde81c39_k.jpg"></a-sphere>
<a-sphere color="#FFEB3B" radius="1" position="4 2 0" set-sky="32252838043_e8f2be6783_k.jpeg"></a-sphere>
<a-sky></a-sky>
</a-scene>
</body>
</html>
我是a-frame的新手,在java脚本中也没有多少工作。 上面的代码适用于引用的图像,但不适用于本地图像。 实际上我做错了什么? 我在这里找到了这个例子。
确保您使用的是本地服务器(例如,Mongoose,python -m SimpleHTTPServer或npm install live-server),并且该图像与您引用表单的index.html
所在的路径相同。
使用https://www.cesanta.com/products/binary ,它易于使用。 无需以任何方式配置服务器结构。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.