elation-engine
Version:
WebGL/WebVR engine written in Javascript
25 lines (22 loc) • 954 B
JavaScript
elation.component.add('engine.things.planet', function() {
this.postinit = function() {
this.defineProperties({
'radius': { type: 'float', default: 1 },
'render.texture': { type: 'texture' },
'render.normalmap': { type: 'texture' },
'render.bumpmap': { type: 'texture' },
'render.heightmap': { type: 'texture' },
});
}
this.createObject3D = function() {
var geo = new THREE.SphereGeometry(this.properties.radius, 32, 16);
var matargs = {};
if (this.properties.radius.texture) matargs.map = this.properties.radius.texture;
if (this.properties.radius.normalmap) matargs.normalMap = this.properties.radius.normalmap;
if (this.properties.radius.bumpmap) matargs.bumpMap = this.properties.radius.bumpMap;
matargs.shininess = 1;
matargs.specular = 0xffffff;
var mat = new THREE.MeshPhongMaterial(matargs);
return new THREE.Mesh(geo, mat);
}
}, elation.engine.things.generic);