/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* Map.js :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: edbernar 0.5) aaaa = 2; if (vec3.z < 0) aaaa = -2; console.log(vec3.z); vec3.z = (vec3.z + 0.01) * aaaa; break; } }); ground.position.copy(groundBody.position); ground.quaternion.copy(groundBody.quaternion); wallBottom.position.copy(wallBottomBody.position); wallBottom.quaternion.copy(wallBottomBody.quaternion); wallTop.position.copy(wallTopBody.position); wallTop.quaternion.copy(wallTopBody.quaternion); speed = 3; if (1) // player1 (right) lose { vec3.x = -3; vec3.y = 0; vec3.z = 0; // vec3.z = Math.floor(Math.random() * 7) - 3; } else { vec3.x = 3; vec3.y = 0; vec3.z = Math.floor(Math.random() * 6) - 3; } ballBody.velocity.set(vec3.x, vec3.y, vec3.z); } static dispose() { if (spotLight) spotLight.dispose(); spotLight = null; } static update() { world.step(timeStep); ball.position.copy(ballBody.position); // ball.quaternion.copy(ballBody.quaternion); player1Body.position.copy(player1.position); // player1Body.quaternion.copy(player1.quaternion); player2Body.position.copy(player2.position); // player2Body.quaternion.copy(player2.quaternion); // if (needUpdate) // { // console.log("vec3", vec3); // needUpdate = false; // } // console.log(ballBody.velocity.length()); speed += 0.003; ballBody.velocity.set(vec3.x * speed, vec3.y * speed, vec3.z * speed); } } function createGround(scene) { const geometry = new THREE.PlaneGeometry(width, height); const material = new THREE.MeshPhysicalMaterial({color: 0x222222}); const mesh = new THREE.Mesh(geometry, material); mesh.rotateX(-Math.PI / 2); mesh.position.set(0, 0, 0); scene.add(mesh); return (mesh); } function createWall(onTop) { const geometry = new THREE.BoxGeometry(width, 0.7, 0.2); const material = new THREE.MeshPhysicalMaterial({color: 0x333333}); const mesh = new THREE.Mesh(geometry, material); // if (onTop) // mesh.position.z = -6.15; // else // mesh.position.z = 6.15; // mesh.position.y += 0.35; return (mesh); } export { Map, wallBottom, wallTop };