This is post is part of the ‘one threex a day’ challenge. This challenge is to publish every day one game extension for three.js! One per day, every day and that for 2month! In this post, we gonna talk about threex.dynamictexture. threex.dynamictexture is a threex game extension for three.js. It provides an easy way to handle dynamically generated texture. Inspiration came from the excelent babylon.js which got BABYLON.DynamicTexture. It is mainly used to write text in texture. Say you got a character which says something, you may want to put that in a texture and display that above your character. threex.dynamictexture will make it easy for you.
To see the other posts about one threex a day and forget our moto! “A THREEx extension a day, gets your game on its way!”
Show Don’t Tell
How To Install It
You can install it manually or with
for the manual version, first include
threex.dynamictexture.js with the usual
or with bower you type the following to install the package.
then you add that in your html
How To Use It ?
You instanciate the texture, say it is 512 pixel width, and 512 pixel high.
dynamicTexture.canvasthe underlying canvas
dynamicTexture.contextthe context of the underlying canvas
To use the texture on a
1 2 3 4 5 6
When you update a texture be sure to do
Some helpers functions are provided to draw in this canvas.
To clear the underlying canvas
To Draw a Text to draw a text