2016-10-07 03:14:07 +00:00
|
|
|
import * as THREE from 'three';
|
2016-09-12 19:54:07 +00:00
|
|
|
|
2016-10-07 03:14:07 +00:00
|
|
|
import Config from '../../data/config';
|
2016-09-12 19:54:07 +00:00
|
|
|
|
|
|
|
export default class Geometry {
|
|
|
|
constructor(scene) {
|
|
|
|
this.scene = scene;
|
|
|
|
this.geo = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
make(type) {
|
|
|
|
if(type == 'plane') {
|
|
|
|
return (width, height, widthSegments = 1, heightSegments = 1) => {
|
|
|
|
this.geo = new THREE.PlaneGeometry(width, height, widthSegments, heightSegments);
|
2016-10-07 03:14:07 +00:00
|
|
|
};
|
2016-09-12 19:54:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
place(position, rotation) {
|
|
|
|
const material = new THREE.MeshStandardMaterial({ color: 0xCCCCCC, side: THREE.DoubleSide });
|
|
|
|
const mesh = new THREE.Mesh(this.geo, material);
|
|
|
|
|
|
|
|
mesh.position.set(...position);
|
|
|
|
mesh.rotation.set(...rotation);
|
|
|
|
|
|
|
|
if(Config.shadow.enabled) {
|
|
|
|
mesh.receiveShadow = true;
|
|
|
|
mesh.castShadow = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.scene.add(mesh);
|
|
|
|
}
|
|
|
|
}
|