diff --git a/js/Cube.js b/js/Cube.js index 36d6d93..8a15f65 100644 --- a/js/Cube.js +++ b/js/Cube.js @@ -1,12 +1,19 @@ import { Element } from "./Element.js"; export class Cube extends Element { - constructor(color) { + constructor(color, img) { super(); + let texture = null; + if (img) { + const loader = new THREE.TextureLoader(); + texture = loader.load(img); + loader.load; + } + this.data = new THREE.Mesh( - new THREE.BoxGeometry(1, 1, 1), - new THREE.MeshBasicMaterial({ color: color }) + new THREE.BoxGeometry(), + new THREE.MeshPhongMaterial({ color: color, map: texture }) ); // Create shadows diff --git a/js/player.js b/js/player.js index 30ef058..05ed082 100644 --- a/js/player.js +++ b/js/player.js @@ -3,9 +3,10 @@ import { Rotation } from "./utils.js"; export class Joueur extends Cube { constructor(color) { - super(color); + super(color, "assets/images/player1.png"); this.data.position.y = 0.5; + this.data.position.x = -2; this.data.rotation.x = this.gameRotation; this.movementData = new Rotation(this.data.position);