I am trying to add numbers to the sides of a decahedron but for some reason the mesh created is invisible there is some issue in the materials. But I am not sure what the issue is. What am i doing wrong ? -
const verticesGeo = [
[0, 0, 1],
[0, 0, -1],
].flat();
for (let i = 0; i < sides; ++i) {
const b = (i * Math.PI * 2) / sides;
verticesGeo.push(-Math.cos(b), -Math.sin(b), 0.105 * (i % 2 ? 1 : -1));
}
const facesGeo = [
[0, 2, 3],
[0, 3, 4],
[0, 4, 5],
[0, 5, 6],
[0, 6, 7],
[0, 7, 8],
[0, 8, 9],
[0, 9, 10],
[0, 10, 11],
[0, 11, 2],
[1, 3, 2],
[1, 4, 3],
[1, 5, 4],
[1, 6, 5],
[1, 7, 6],
[1, 8, 7],
[1, 9, 8],
[1, 10, 9],
[1, 11, 10],
[1, 2, 11],
].flat();
const args = [verticesGeo, facesGeo, radius, 0];
let decaGeometry = new THREE.PolyhedronGeometry(...args);
let g = decaGeometry;
let materialOptions = {
specular: 0x172022,
color: 0xf0f0f0,
shininess: 40,
flatShading: true,
//shading: THREE.FlatShading,
};
let materials = [];
for (let text = 0; text < 10; ++text) {
let canvas = document.createElement("canvas");
let context = canvas.getContext("2d");
let ts = Math.max(128, Math.pow(2, Math.floor(Math.log(1.5) / Math.log(2)))) * 2;
canvas.width = canvas.height = ts;
context.font = ts / (1 + 2 * 1) + "pt Arial";
context.fillStyle = tempFillColor;
context.fillRect(0, 0, canvas.width, canvas.height);
context.textAlign = "center";
context.textBaseline = "middle";
context.fillStyle = tempTextColor;
context.fillText(text, canvas.width / 2, canvas.height / 2);
let texture = new THREE.Texture(canvas);
texture.needsUpdate = true;
materials.push(new THREE.MeshPhongMaterial(Object.assign({}, materialOptions, { map: texture })));
}
console.log(materials)
decahedron = new THREE.Mesh(g, materials);
scene.add(decahedron)