- Updating/creating ball ball
This commit is contained in:
Kum1ta
2024-08-20 17:37:06 +02:00
parent d46f1636b4
commit 89e60305e1
7 changed files with 925 additions and 79 deletions

View File

@ -0,0 +1,45 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Ball.js :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/20 17:02:47 by edbernar #+# #+# */
/* Updated: 2024/08/20 17:23:41 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
import * as THREE from 'three';
const centerPos = {
x: 0,
y: 0.3,
z: -0.1
}
class Ball
{
object = null;
constructor(scene)
{
this.object = this.#createBall();
scene.add(this.object);
}
#createBall()
{
const geometry = new THREE.SphereGeometry(0.15);
const material = new THREE.MeshPhysicalMaterial({ color: 0xff5555 });
const mesh = new THREE.Mesh(geometry, material);
mesh.receiveShadow = true;
mesh.castShadow = true;
mesh.position.set(centerPos.x, centerPos.y, centerPos.z);
return (mesh);
}
}
export { Ball };