make(type) { if(type === 'plane') { return (width, height, widthSegments = 1, heightSegments = 1) => { this.geo = new THREE.PlaneGeometry(width, height, widthSegments, heightSegments); }; } if(type === 'sphere') { return (radius, widthSegments = 32, heightSegments = 32) => { this.geo = new THREE.SphereGeometry(radius, widthSegments, heightSegments); }; } }
Object.keys(R_BLOCKS).forEach(key => { const { func, rotation, translation } = R_BLOCKS[key] this.geometries[key] = { geometry: new THREE.PlaneGeometry(DIMENSION, DIMENSION), translation } if (func) { if (Array.isArray(func)) { for (let i = 0; i < func.length; i++) this.geometries[key].geometry[func[i]](rotation[i]) } else this.geometries[key].geometry[func](rotation) } this.pures[key] = { geometry: this.geometries[key].geometry.clone(), translation: this.geometries[key].translation } })
plane() { const geometry = new THREE.PlaneGeometry(); const material = new THREE.MeshBasicMaterial({ color: Math.random() * 0xffffff, side: THREE.DoubleSide }); return new THREE.Mesh(geometry, material); }