gpt4 book ai didi

javascript - Aframe 回调未调用

转载 作者:行者123 更新时间:2023-12-03 04:27:58 25 4
gpt4 key购买 nike

我有一个相机运动回调函数,在 aframe 中实现。但回调永远不会被调用。我正在像这样注册组件:

window.onload = function () {
AFRAME.registerComponent('listener', {
tick: function () {
console.log("TICK IS CALLED");
}
});
addMaze();
};

场景如下:

<body>
<a-scene physics id="a">
<a-entity position="33 0 -33" rotation="0 180 0" id="camera" camera="userHeight: 1.6" kinematic-body universal-controls listener>
</a-entity>

<!-- walls -->
<a-box color="#abc" static-body position="-35 0 0" width="0.001" height="6" depth="70"></a-box>
<a-box color="#abc" static-body position="35 0 0" width="0.001" height="6" depth="70"></a-box>

<!-- Lighting -->
<a-light type="ambient" color="#bbb"></a-light>
<a-light color="#ccc" position="0 30 0" distance="100" intensity="0.4" type="point"></a-light>
<a-light color="#ccc" position="3 10 -10" distance="50" intensity="0.4" type="point"></a-light>

</a-scene>
</body>

当移动鼠标时,回调函数永远不会被调用。如何确保它被正确调用?

最佳答案

组件应该在发生任何事情之前注册。

<head>
<script>
AFRAME.registerComponent('listener', {...});
</script>
</head>
<body>
<a-scene>
<!-- ... -->
</a-scene>
</body>

关于javascript - Aframe 回调未调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43617876/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com