@prisoner849 , I tried the method you advised but then the mesh is not visible-
const radius = 1.3;
const verticesGeo = [
[0, 0, 1],
[0, 0, -1],
].flat();
const sides = 10;
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();
for (let i = 0; i < 10; i++) {
const geometry = new THREE.BufferGeometry();
// Creating vertices
const vertices = [];
for (let j = 0; j < verticesGeo.length; j += 3) {
vertices.push(verticesGeo[j], verticesGeo[j + 1], verticesGeo[j + 2]);
}
geometry.setAttribute('position', new THREE.Float32BufferAttribute(vertices, 3));
// Creating faces
const indices = facesGeo.slice(i * 6, i * 6 + 6);
geometry.setIndex(indices);
// Create UVs
const uvs = new Float32Array(vertices.length / 3 * 2);
for (let j = 0; j < uvs.length; j += 2) {
uvs[j] = (j % 4) / 4;
uvs[j + 1] = (j % 4) / 4;
}
geometry.setAttribute('uv', new THREE.Float32BufferAttribute(uvs, 2));
// Create canvas for text
const canvas = document.createElement('canvas');
canvas.width = tileSize;
canvas.height = tileSize;
const ctx = canvas.getContext('2d');
// Fill background
ctx.fillStyle = tempFillColor;
ctx.fillRect(0, 0, tileSize, tileSize);
// Draw text
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = `bold ${tileSize / 3}px Calistoga`;
ctx.fillStyle = tempTextColor;
ctx.fillText(
i + 1,
tileSize / 2,
tileSize / 2
);
const texture = new THREE.CanvasTexture(canvas);
const material = new THREE.MeshBasicMaterial({ map: texture });
materials.push(material);
geometries.push(geometry);
}
const mergedGeometry = BufferGeometryUtils.mergeBufferGeometries(geometries);
decahedron = new THREE.Mesh(mergedGeometry, materials);