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 {
|
||||
constructor() {
|
||||
this.data = new THREE.Mesh(
|
||||
new THREE.BoxGeometry(1, 1, 1),
|
||||
new THREE.MeshBasicMaterial({ color: 0x00ff00 })
|
||||
);
|
||||
this.data = undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate the element
|
||||
*/
|
||||
rotate = () => {
|
||||
this.data.rotation.x += 0.01;
|
||||
this.data.rotation.y += 0.01;
|
||||
if (this.data) {
|
||||
this.data.rotation.x += 0.01;
|
||||
this.data.rotation.y += 0.01;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Reference in a new issue