three-spritetext icon indicating copy to clipboard operation
three-spritetext copied to clipboard

How to offset a text?

Open benderlidze opened this issue 5 years ago • 4 comments

The text is always in the center of the node. How can I put it a little lower? Thanks

benderlidze avatar Oct 09 '19 19:10 benderlidze

@benderlidze the module doesn't currently support offsets. But I'll gladly take a PR if you wish to upgrade it. The offset value would be used to manipulate the fillText position parameters at https://github.com/vasturiano/three-spritetext/blob/master/src/index.js#L63

Current behavior should remain the default to prevent any regression.

vasturiano avatar Oct 10 '19 20:10 vasturiano

Sprite#center may be of assistance, though I don't know if it supports numbers out of [0;1] range.

ettavolt avatar Dec 04 '19 15:12 ettavolt

wouldn't this be possible by manipulating the center of the sprite? i get this when i set it to:

myText.position.set(x, y, z) // x, y, z is the top-center of the rectangle
myText.material.rotation = Math.PI / 8
myText.center = new THREE.Vector2(0, 0)
image

mgiraldo avatar Mar 02 '20 04:03 mgiraldo

Couldnt you just use the position property to do the offset? Example here, https://github.com/protectwise/troika/tree/main/packages/troika-three-text#usage

tqtran7 avatar Aug 11 '22 17:08 tqtran7