use image and move player to the left

This commit is contained in:
Mylloon 2022-11-24 17:56:26 +01:00
parent 91d8e577ba
commit 33fa6fe5a9
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 12 additions and 4 deletions

View file

@ -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

View file

@ -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);