UNPKG

meta-client

Version:
36 lines (26 loc) 968 B
import {CubeGeometry, SphereGeometry, CylinderGeometry, MeshPhongMaterial, Mesh} from 'three'; class Materia { constructor(data){ var OBJECT, COLOR; if(data.color!=undefined) {COLOR = data.color; } else {COLOR = {r:55,g:55,b:55}}; switch(data.object){ //TODO these guys must be accessible somewhere public case 0: OBJECT = new Mesh(new CubeGeometry(.1,.1,.1), new MeshPhongMaterial({color:COLOR})) break; case 1: OBJECT = new Mesh(new SphereGeometry(.1,32,32), new MeshPhongMaterial({color:COLOR})) break; case 2: OBJECT = new Mesh(new CylinderGeometry( 0, .5, .5, 32, 32 ), new MeshPhongMaterial({color:COLOR})) break; } if(data.color!=undefined) OBJECT.material.color.set(data.color); OBJECT.position.copy(data.position); OBJECT.userData._id = data._id; return OBJECT; //TODO on(), go() //TODO live('on'), live('again') } } export default Materia;