if (useLights) {
// material = new THREE.MeshLambertMaterial
material = new THREE.MeshPhongMaterial({ color: baseColor, opacity: baseOpacity, transparent: baseOpacity<1, vertexColors: applyDiffFaceColors });
baseMaterial = new THREE.MeshPhongMaterial({ color: baseColor, opacity: baseOpacity, transparent: baseOpacity<1, vertexColors: applyDiffFaceColors });
}
else {
material = new THREE.MeshBasicMaterial({ color: baseColor, opacity: baseOpacity, transparent: baseOpacity<1, vertexColors: applyDiffFaceColors});
baseMaterial = new THREE.MeshBasicMaterial({ color: baseColor, opacity: baseOpacity, transparent: baseOpacity<1, vertexColors: applyDiffFaceColors });
}
if (useText){
var letterWidth = 30;
if (text==null)
text = boxes.length.toString();
var bitmap = document.createElement('canvas');
var ctx = bitmap.getContext('2d');
ctx.font = letterWidth.toString() + 'px ' + font;
var measuredText = ctx.measureText(text);
var textWidht = measuredText.width;
var textHeight = letterWidth * 1.0;
var bitmapSize = Math.max(200, textWidht);
bitmap.width = bitmapSize;
bitmap.height = bitmapSize;
ctx.font = letterWidth.toString() + 'px ' + font;
ctx.fillStyle = 'white'; // due to opacity it will not affect material fill color
ctx.fillRect(0, 0, bitmap.width, bitmap.height);
ctx.fillStyle = 'white';
ctx.strokeStyle = 'black';
ctx.fillText(text, (bitmapSize - textWidht)/2, (bitmapSize - textHeight *(1-1))/2); // left lower corner
ctx.strokeText(text, (bitmapSize - textWidht)/2, (bitmapSize - textHeight *(1-1))/2); // left lower corner
var texture = new THREE.CanvasTexture(bitmap)
material.map = texture;