Avatar of Pradip Shenolkar
Pradip ShenolkarFlag for India

asked on 

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
JavaScript

Avatar of undefined
Last Comment
Pradip Shenolkar
Avatar of ozo
ozo
Flag of United States of America image

"hello<br>world"
Avatar of Pradip Shenolkar

ASKER

@ ozo : That's  not right.
Avatar of Steve Bink
Steve Bink
Flag of United States of America image

You'll need to execute two writes - one for "Hello" and one for "World" - using different y locations.
Avatar of Pradip Shenolkar

ASKER

@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 ?
ASKER CERTIFIED SOLUTION
Avatar of Steve Bink
Steve Bink
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Pradip Shenolkar

ASKER

I think you brought me more close to answer.
According to your code "Hello" is overlapped by "World".
Avatar of Steve Bink
Steve Bink
Flag of United States of America image

Then adjust the "y" values until they don't overlap.
Avatar of Pradip Shenolkar

ASKER

Above Accepted Solution is working.

Sorry for rejecting it.
solution.png
JavaScript
JavaScript

JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.

127K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo