/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* MultiGame.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() { debug = false; if (renderer) renderer.dispose(); renderer = null; if (map) map.dispose(); map = null; if (ball) ball.dispose(); ball = null; if (player) player.dispose(); player = null; if (opponent) opponent.dispose(); opponent = null; if (scene) { scene.children.forEach(child => { if (child.geometry) child.geometry.dispose(); if (child.material) child.material.dispose(); if (child.texture) child.texture.dispose(); scene.remove(child); }); } scene = null; } } 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(); } export { MultiGame, stats };