Clickable Sprite Labels?

2019-07-24 01:36发布

I’ve been playing with sprite text labels and more specifically with this example: http://stemkoski.github.io/Three.js/Sprite-Text-Labels.html and I was just wondering if it is possible to somehow assign an id to a sprite variable so that when the sprite is clicked on, an action occurs?

In my example “Hello“ and “World” are two separate variables:

var spriteHello = makeTextSprite ( "Hello", 
                  { fontsize: 24, borderColor: {r:255, g:0, b:0, a:1.0},
                  backgroundColor: {r:255, g:100, b:100, a:0.8} }  );
spriteHello.position.set(100,55,55);
scene.add( spriteHello );

var spriteWorld = makeTextSprite ( "World", 
                  { fontsize: 32, fontface: "Georgia", 
                  borderColor: {r:0, g:0, b:255, a:1.0} } );
spriteWorld.position.set(55,105,55);
scene.add( spriteWorld );  

Or is there another way of doing this with using this specific example? Thanks!

0条回答
登录 后发表回答