I saw some codes and I tried to compile them together. It doesn't work and I might miss something.
Two issues,
movekamera
) instead of a call (movekamera()
)<a-animation>
is deprecated - use animation instead.Your code with these changes:
<script src="https://aframe.io/releases/1.1.0/aframe.min.js"></script>
<a-scene background="color: #FAFAFA">
<a-entity
id="mouseCursor"
cursor="rayOrigin: mouse"
raycaster="objects: #box,#plane,#cylinder"
></a-entity>
<a-entity
id="box"
geometry="primitive: box"
material="color: red"
position="-1 1 -3"
rotation="0 30 0"
onclick="kameramove_1()"
></a-entity>
<a-cylinder
id="cylinder"
position="1 0.75 -3"
radius="0.5"
height="1.5"
color="#FFC65D"
shadow
onclick="kameramove_1_back()"
></a-cylinder>
<a-plane
id="plane"
position="0 0 -4"
rotation="-90 0 0"
width="4"
height="4"
color="#7BC8A4"
onclick="kameramove_1()"
>
</a-plane>
<a-entity movement-controls="fly: true" position="0 0 0"></a-entity>
<a-entity camera position="0 1.6 0" look-controls></a-entity>
<a-entity id="camentity" rotation="0 0 0"
animation__1="property: position; from: 0 0 0; to: -4 0 -5; dur: 500;
startEvents: movecam_1"
animation__bc ="property: position; to: 0 0 0; from: -4 0 -5; dur: 500; startEvents: movecam_1_bc">
<a-camera id="cam"></a-camera>
</a-entity>
</a-scene>
<script>
function kameramove_1() {
document.querySelector("#cam").emit("movecam_1");
}
function kameramove_1_back() {
document.querySelector("#cam").emit("movecam_1_bc");
}
</script>