extend Element for a Cube class
This commit is contained in:
parent
9a352e7789
commit
819c89e92f
2 changed files with 17 additions and 6 deletions
12
js/Cube.js
Normal file
12
js/Cube.js
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import { Element } from "./Element.js";
|
||||||
|
|
||||||
|
export class Cube extends Element {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.data = new THREE.Mesh(
|
||||||
|
new THREE.BoxGeometry(1, 1, 1),
|
||||||
|
new THREE.MeshBasicMaterial({ color: 0x00ff00 })
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,16 +1,15 @@
|
||||||
export class Element {
|
export class Element {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.data = new THREE.Mesh(
|
this.data = undefined;
|
||||||
new THREE.BoxGeometry(1, 1, 1),
|
|
||||||
new THREE.MeshBasicMaterial({ color: 0x00ff00 })
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rotate the element
|
* Rotate the element
|
||||||
*/
|
*/
|
||||||
rotate = () => {
|
rotate = () => {
|
||||||
this.data.rotation.x += 0.01;
|
if (this.data) {
|
||||||
this.data.rotation.y += 0.01;
|
this.data.rotation.x += 0.01;
|
||||||
|
this.data.rotation.y += 0.01;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue