use image and move player to the left
This commit is contained in:
parent
91d8e577ba
commit
33fa6fe5a9
2 changed files with 12 additions and 4 deletions
13
js/Cube.js
13
js/Cube.js
|
@ -1,12 +1,19 @@
|
||||||
import { Element } from "./Element.js";
|
import { Element } from "./Element.js";
|
||||||
|
|
||||||
export class Cube extends Element {
|
export class Cube extends Element {
|
||||||
constructor(color) {
|
constructor(color, img) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
let texture = null;
|
||||||
|
if (img) {
|
||||||
|
const loader = new THREE.TextureLoader();
|
||||||
|
texture = loader.load(img);
|
||||||
|
loader.load;
|
||||||
|
}
|
||||||
|
|
||||||
this.data = new THREE.Mesh(
|
this.data = new THREE.Mesh(
|
||||||
new THREE.BoxGeometry(1, 1, 1),
|
new THREE.BoxGeometry(),
|
||||||
new THREE.MeshBasicMaterial({ color: color })
|
new THREE.MeshPhongMaterial({ color: color, map: texture })
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create shadows
|
// Create shadows
|
||||||
|
|
|
@ -3,9 +3,10 @@ import { Rotation } from "./utils.js";
|
||||||
|
|
||||||
export class Joueur extends Cube {
|
export class Joueur extends Cube {
|
||||||
constructor(color) {
|
constructor(color) {
|
||||||
super(color);
|
super(color, "assets/images/player1.png");
|
||||||
|
|
||||||
this.data.position.y = 0.5;
|
this.data.position.y = 0.5;
|
||||||
|
this.data.position.x = -2;
|
||||||
this.data.rotation.x = this.gameRotation;
|
this.data.rotation.x = this.gameRotation;
|
||||||
|
|
||||||
this.movementData = new Rotation(this.data.position);
|
this.movementData = new Rotation(this.data.position);
|
||||||
|
|
Reference in a new issue