I have a basic THREE.js TextGeometry object in my scene:
const loader = new THREE.FontLoader();
const linkToFont ='link-to-font';
let textGeo;
const self = this;
loader.load(linkToFont, function (font) {
textGeo = new THREE.TextGeometry('Hello three.js!', {
font,
size: 0.3,
height: 0.01,
});
textGeo.computeBoundingBox();
const textMaterial = new THREE.MeshBasicMaterial({ color: 0xff0000 });
const textMesh = new THREE.Mesh(textGeo, textMaterial);
textMesh.position.set(-100, 0, 0);
textMesh.updateMatrixWorld();
self.addToScene(textMesh);
});
This renders text in red on my scene. Is it possible to give the text in this area a "background color"? I.e. a rectangular solid color behind the text itself?
You have 2 options:
scene.background = new THREE.Color(0x9900ff).MeshBasicMaterial.