Hello,
I’m having trouble in modifying a gradient applied to a TextGeometry.
https://codepen.io/lucgenti/pen/WdybLg
The gradient I’m trying to apply is this one:
https://jsfiddle.net/lucav/zLw1jw80/
I took the algorithm for the gradient from there:
https://stemkoski.github.io/Three.js/Vertex-Colors.html (last cube)
Basically is using the position in the space of the point in the vertex to calculate the colors on each Face3. But there’s a way to do this way to make a more complex gradient?
I also tried a simpler approach with the canvas, but I din’t make it work (can’t draw a Rect from bottom to top on the arc of the letter).
var texture = new THREE.Texture( generateTexture() );
texture.needsUpdate = true;
var materials = [
new THREE.MeshBasicMaterial( { color: '#ECECEE', overdraw: 0.5 } ),
new THREE.MeshBasicMaterial( { map: texture, overdraw: 0.5, transparent: true } )
];
function generateTexture() {
var size = 25;
canvas = document.createElement( 'canvas' );
canvas.width = size;
canvas.height = size;
var context = canvas.getContext( '2d' );
var gradient = context.createLinearGradient( 0, 0, size, 0 );
gradient.addColorStop(0, '#f7b000');
gradient.addColorStop(0.25, '#dd0080');
gradient.addColorStop(0.5, '#622b85');
gradient.addColorStop(0.75, '#007dae');
gradient.addColorStop(1, '#77c8db');
context.fillStyle = gradient;
context.fillRect(size/1.6, 7, size, size);
return canvas;
}