Skip to content

Commit eb98c5c

Browse files
dakersankhesh
authored andcommitted
fix(VectorText): fix perLetterFaceColors
fixes #3311
1 parent 3953b55 commit eb98c5c

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

Sources/Rendering/Core/VectorText/Utils.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,8 @@ function addTriangle(
459459
uvArray.push(uv[0], uv[1]);
460460
});
461461
if (colorArray && color) {
462-
for (let i = 0; i < 3; ++i) colorArray.push(color[0], color[1], color[2]);
462+
for (let i = 0; i < 3; ++i)
463+
colorArray.push(color[0] * 255, color[1] * 255, color[2] * 255);
463464
}
464465
}
465466

@@ -512,7 +513,8 @@ function addQuad(
512513
uvArray.push(uvs[3][0], uvs[3][1]);
513514

514515
if (colorArray && color) {
515-
for (let i = 0; i < 6; ++i) colorArray.push(color[0], color[1], color[2]);
516+
for (let i = 0; i < 6; ++i)
517+
colorArray.push(color[0] * 255, color[1] * 255, color[2] * 255);
516518
}
517519
}
518520

Sources/Rendering/Core/VectorText/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ function vtkVectorText(publicAPI, model) {
328328
let letterIndex = 0;
329329
model.shapes.forEach((shape) => {
330330
let color = null;
331-
if (typeof model.perLetterFaceColors === 'function') {
331+
if (model.perLetterFaceColors) {
332332
color = model.perLetterFaceColors(letterIndex) || [1, 1, 1];
333333
}
334334
addShape(shape, offsetSize, color);
@@ -356,12 +356,12 @@ function vtkVectorText(publicAPI, model) {
356356
polyData.setPolys(cells);
357357

358358
// Set points (vertices)
359-
polyData.getPoints().setData(new Float32Array(model.verticesArray), 3);
359+
polyData.getPoints().setData(Float32Array.from(model.verticesArray), 3);
360360

361361
// Set texture coordinates
362362
const da = vtkDataArray.newInstance({
363363
numberOfComponents: 2,
364-
values: new Float32Array(model.uvArray),
364+
values: Float32Array.from(model.uvArray),
365365
name: 'TEXCOORD_0',
366366
});
367367
pointData.addArray(da);
@@ -371,7 +371,7 @@ function vtkVectorText(publicAPI, model) {
371371
if (model.colorArray && model.colorArray.length) {
372372
const ca = vtkDataArray.newInstance({
373373
numberOfComponents: 3,
374-
values: new Float32Array(model.colorArray),
374+
values: Uint8Array.from(model.colorArray),
375375
name: 'Colors',
376376
});
377377
pointData.addArray(ca);

0 commit comments

Comments
 (0)