requestAnimationFrame(loop); y estoy tratando de hacer clic en el botón para iniciar la animación, una vez que lo presionas, la animación comienza, descubrí el botón <button type="start" form="form1" value="start onclick="start()">start</button> Pero no sé cómo convertirlo en un script.
Si desea llamar a requestAnimationFrame(loop) , debe hacerlo así ...
<button type="start" form="form1" value="start" onclick="requestAnimationFrame(loop)">start</button>Aquí hay un fragmento de ejemplo:
<button onclick="start()">start</button> <script> var animId=false; function start() { animId=requestAnimationFrame(loop); } function loop() { //your code here } // I added this in case you wanted to call a stop function stop() { animId && cancelAnimationFrame(animId); } </script>