antho
antho

Reputation: 85

Getting a text included in a Mesh

i need some help in my webGL code. I created a TextGeometry and i included it in a mesh, i didn't have any problem about that. However, i would like updating this text without creating another TextGeometry.

Indeed, my main goal is to translate a text (from right to left) and to make it disappear when he reaches to the left side, but only character by character (like a fade effect).

I tried some attempts : for example, according to text position, deleting it with a : scene.remove(text) and creating another text which is the same as previously minus the first character. I don't know if i was clear... But this solution makes my application very slow : that's why i don't want creating an Object every time, but just updating his text property.

I didn't find many help in three.js documentation, may you give me a hand about that ? Cheers

Upvotes: 1

Views: 438

Answers (1)

Stemkoski
Stemkoski

Reputation: 9045

You could try this:

Create a PlaneGeometry and texture it using the image from a hidden canvas object that contains your text, then apply image transforms to the canvas itself (fading as necessary) and continually update the texture in Three.js as it moves across the scene.

For an example of how to use a canvas object as an image (of text), I have an example posted at: http://stemkoski.github.com/Three.js/Texture-From-Canvas.html

Upvotes: 1

Related Questions