Aframe 使用凝视光标示例时无法更改相机视图
我使用了中的示例代码,并将其插入样板页:Aframe 使用凝视光标示例时无法更改相机视图,aframe,Aframe,我使用了中的示例代码,并将其插入样板页: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Hello, World! • A-Frame</title> <meta name="description" content="Hello, World! • A-Frame"> <script src="
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello, World! • A-Frame</title>
<meta name="description" content="Hello, World! • A-Frame">
<script src="https://cdnjs.cloudflare.com/ajax/libs/aframe/0.7.0/aframe-master.js"></script>
<script>
AFRAME.registerComponent('cursor-listener', {
init: function () {
var lastIndex = -1;
var COLORS = ['red', 'green', 'blue'];
this.el.addEventListener('click', function (evt) {
lastIndex = (lastIndex + 1) % COLORS.length;
this.setAttribute('material', 'color', COLORS[lastIndex]);
console.log('I was clicked at: ', evt.detail.intersection.point);
});
}
});
</script>
</head>
<body>
<a-scene>
<a-entity camera>
<a-entity cursor="fuse: true; fuseTimeout: 500"
position="0 0 -1"
geometry="primitive: ring; radiusInner: 0.02; radiusOuter: 0.03"
material="color: black; shader: flat">
</a-entity>
</a-entity>
<a-entity id="box" cursor-listener geometry="primitive: box" material="color: blue" position="0, 0, -4"></a-entity>
</a-scene>
</body>
</html>
你好,世界人字架
AFRAME.registerComponent('cursor-listener'{
init:函数(){
var lastIndex=-1;
变量颜色=['红色'、'绿色'、'蓝色'];
this.el.addEventListener('click',函数(evt){
lastIndex=(lastIndex+1)%COLORS.length;
this.setAttribute('material','color',COLORS[lastIndex]);
log('我被点击在:',evt.detail.intersection.point);
});
}
});
如何修复代码以允许我移动相机?您需要将“外观控制”组件添加到相机:
您需要将“外观控制”组件添加到相机中: