/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.js :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: edbernar { if (e.key == 'g') player.pointAnimation(map); if (e.key == 'h') player.pointOpponentAnimation(map, opponent.object); if (e.key == 'c') debug = !debug; }) renderer.setAnimationLoop(loop) } static dispose() { scene = null; debug = false; } } function createBarPlayer(color) { const geometry = new THREE.BoxGeometry(1, 0.1, 0.1); const material = new THREE.MeshPhysicalMaterial({color: color}); const mesh = new THREE.Mesh(geometry, material); mesh.castShadow = true; return (mesh); } function loop() { stats.begin(); // ===== FPS locker ===== // if (fpsLocker.status) { const currentTime = Date.now(); if (currentTime - previousTime < 1000 / 60) return ; previousTime = currentTime; } // ====================== // player.update(); map.update(ball); if (debug) { controls.update(); renderer.render(scene, cameraTmp); } else renderer.render(scene, player.camera); stats.end(); } Game.create();