Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


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

Posted on 2015-02-19
Medium Priority
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.drawText("Hello World", undefined, 256, 'black');

Open in new window

Question by:Pradip Shenolkar
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
LVL 84

Expert Comment

ID: 40620398

Author Comment

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

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.
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!


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 ?
LVL 51

Accepted Solution

Steve Bink earned 2000 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


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".
LVL 51

Expert Comment

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

Author Closing Comment

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

Sorry for rejecting it.

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

715 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