Admin Admin
Posts : 46 Points : 78 Reputation : 3 Join date : 2017-02-06 Location : London, Milan
| Subject: Materials Editor based on Slots Fri Feb 24, 2017 10:57 am | |
| I was working on a way to define more materials in one project and I needed to create a kind of simple mat slots. This is the code I created for this purpose: to implement more materials than can be assigned to object at your choise. - Code:
-
/* HTML input which contains a list of mat numbers */ <div> <input type="text" class="plastiInput" id="materialSlots"> </div>
/* Javascript function */ /* Declare array */ var materials = []; /* Numbers of materials in slots */ var maxNumbMat = 8;
var matSlots = document.getElementById('materialSlots'); for (var m = 0; m < maxNumbMat; m++) { var mat = new THREE.MeshPhongMaterial( { color: 0xffffff, shininess: 180, specular: 0x222222, shading: THREE.SmoothShading }); materials.push(mat); matSlots.value = (matSlots.value + m + ','); }
| |
|