This repository has been archived on 2022-12-05. You can view files and clone it, but cannot push or open issues or pull requests.
GeometryDash3D/js/Cube.js

25 lines
561 B
JavaScript
Raw Normal View History

2022-11-22 10:40:13 +01:00
import { Element } from "./Element.js";
export class Cube extends Element {
2022-11-24 17:56:26 +01:00
constructor(color, img) {
2022-11-22 10:40:13 +01:00
super();
2022-11-24 17:56:26 +01:00
let texture = null;
if (img) {
const loader = new THREE.TextureLoader();
texture = loader.load(img);
}
2022-11-22 10:40:13 +01:00
this.data = new THREE.Mesh(
2022-11-24 17:56:26 +01:00
new THREE.BoxGeometry(),
new THREE.MeshPhongMaterial({ color: color, map: texture })
2022-11-22 10:40:13 +01:00
);
// Create shadows
this.data.castShadow = true;
2022-11-24 21:01:14 +01:00
// Move up
this.data.position.y = 0.5;
2022-11-22 10:40:13 +01:00
}
}