ThreeJS-Webpack-ES6-Boilerp.../src/js/app/helpers/geometry.js

34 lines
792 B
JavaScript
Raw Normal View History

import * as THREE from 'three';
2016-09-12 19:54: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-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);
}
}