Saturday, June 1, 2024
 Popular · Latest · Hot · Upcoming
127
rated 0 times [  131] [ 4]  / answers: 1 / hits: 24905  / 8 Years ago, tue, june 28, 2016, 12:00:00

I have added text into my object (a shirt model) using a text geometry. Here is my code:



var canvas = document.getElementById('myCanvas');
var ctx = canvas.getContext('2d');
ctx.font = 'italic 18px Arial';
ctx.textAlign = 'center';
ctx. textBaseline = 'middle';
ctx.fillStyle = 'red';
ctx.fillText('Your Text', 150, 50);`


My output looks like this:



enter



The text does not fit into the shirt model. If I rotate the shirt model means text showing irrelevant view. I want to fit the text into the shirt model like this:



enter



How can I fit my dynamic text into the shirt model using three.js.


More From » canvas

 Answers
8

Simply drawing the text to your 2D canvas will most likely never give you a satisfactory result. You have three possibilities to tackle this issue.



  1. Using textures loaded with a THREE.TextureLoader.




  1. Using THREE.TextGeometry:




  1. Using a CSS3D solution.





Check also the UI example on the THREE.TextGeometry documentation page:


enter


[#61604] Sunday, June 26, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
arthur

Total Points: 729
Total Questions: 107
Total Answers: 109

Location: China
Member since Mon, Aug 22, 2022
2 Years ago
;