Solved

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

Posted on 2015-02-19
8
95 Views
Last Modified: 2015-02-20
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
0
Comment
Question by:Pradip Shenolkar
  • 4
  • 3
8 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 40620398
"hello<br>world"
0
 

Author Comment

by:Pradip Shenolkar
ID: 40620404
@ ozo : That's  not right.
0
 
LVL 50

Expert Comment

by:Steve Bink
ID: 40620468
You'll need to execute two writes - one for "Hello" and one for "World" - using different y locations.
0
 

Author Comment

by:Pradip Shenolkar
ID: 40620516
@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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 50

Accepted Solution

by:
Steve Bink earned 500 total points
ID: 40620655
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
 

Author Comment

by:Pradip Shenolkar
ID: 40620676
I think you brought me more close to answer.
According to your code "Hello" is overlapped by "World".
0
 
LVL 50

Expert Comment

by:Steve Bink
ID: 40621187
Then adjust the "y" values until they don't overlap.
0
 

Author Closing Comment

by:Pradip Shenolkar
ID: 40621288
Above Accepted Solution is working.

Sorry for rejecting it.
solution.png
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How does Redux fit into React? 3 67
Javascript create file issue 4 47
Form with Modals 16 42
Angular - "nest" service calls? 18 22
When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now