In three js (javascript library) how to add text in next line ?

As seen in image (see below, 1.png)  "Hello World" is displayed in one line.
I want to display "Hello" first and on next line "World"

                   
dynamicTexture3	= new THREEx.DynamicTexture(512,512);
                    dynamicTexture3.context.font	= (0.2*512)+"px Arial";
                    dynamicTexture3.clear('cyan');
                    dynamicTexture3.drawText("Hello World", undefined, 256, 'black');

Open in new window

1.png
Pradip ShenolkarAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Steve BinkConnect With a Mentor Commented:
I'm not at all familiar with threex, so I'm afraid I won't be of much help.  My earlier suggestion was made after a brief examination of the source, and some assumptions about the primary library.  Working from there, I would think you do something like this:
dynamicTexture3.drawText("Hello", undefined, 250, 'black')
               .drawText("World", undefined, 262, 'black');

Open in new window

0
 
ozoCommented:
"hello<br>world"
0
 
Pradip ShenolkarAuthor Commented:
@ ozo : That's  not right.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
Steve BinkCommented:
You'll need to execute two writes - one for "Hello" and one for "World" - using different y locations.
0
 
Pradip ShenolkarAuthor Commented:
@Steve Bink : It is a texture on which I am writing "Hello World". I have attached that texture on Cube geometry.
First step what I do is create a texture with "Hello world" and then I attach it to Cube geometry in three js.
So keeping these things in mind could you guide me ?
0
 
Pradip ShenolkarAuthor Commented:
I think you brought me more close to answer.
According to your code "Hello" is overlapped by "World".
0
 
Steve BinkCommented:
Then adjust the "y" values until they don't overlap.
0
 
Pradip ShenolkarAuthor Commented:
Above Accepted Solution is working.

Sorry for rejecting it.
solution.png
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.