Skip to content

Instantly share code, notes, and snippets.

@glumb
Created January 26, 2016 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glumb/fbe22f29ace6322bc986 to your computer and use it in GitHub Desktop.
Save glumb/fbe22f29ace6322bc986 to your computer and use it in GitHub Desktop.
// create a canvas element
var canvas1 = document.createElement('canvas');
var context1 = canvas1.getContext('2d');
context1.font = "Bold 20px Arial";
context1.fillStyle = "rgba(0,0,0,0.95)";
context1.fillText('Hello, world!', 0, 20);
document.getElementsByTagName('body')[0].appendChild(canvas1);
// canvas contents will be used for a texture
var texture1 = new THREE.Texture(canvas1)
texture1.needsUpdate = false;
setInterval(function () {
context1.clearRect(0, 0, canvas1.width, canvas1.height);
var message = 'abpppee' + i++;
context1.fillText(message, 4, 20);
texture1.needsUpdate = true;
}, 1000)
////////////////////////////////////////
var spriteMaterial = new THREE.SpriteMaterial({
map: texture1,
useScreenCoordinates: false
//alignment: THREE.SpriteAlignment.topLeft
});
var sprite1 = new THREE.Sprite(spriteMaterial);
sprite1.scale.set(2000, 1000, 1.0);
sprite1.position.set(50, 50, 0);
scene.add(sprite1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment