Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Three.js: Possible to flip a sprite?

Tags:

three.js

Question: Is it possible to flip/mirror a Three.js sprites texture?

Background: Using the current DEV branch of three.js

Findings so far: I first try'd to change it's 3d rotation without any effect. Then I inspected the sprites code and saw that the rotation is reseted in this line in Sprite.js:

this.rotation3d.set( 0, 0, this.rotation );

Changing the values there didn't had any effect. Digging deeper I ended up in the SpriteRenderer plugin where I got completely lost.

My understanding is that three.js is using shaders to render sprites and that this is a huge performance plus. So writing my own sprite implementation using simple faces feels like the wrong direction.

like image 483
Andreas Hoffmann Avatar asked Dec 27 '12 09:12

Andreas Hoffmann


2 Answers

Okey, this is a long shot, but try setting your sprite's scale to -1 (in the directions you want to flip it).

like image 51
Bartek Banachewicz Avatar answered Sep 22 '22 00:09

Bartek Banachewicz


Just posting it as an alternative:

texture = new three60.THREE.Texture(video);
texture.repeat.set(-1, 1);
texture.offset.set( 1, 0);
like image 22
Matyas Avatar answered Sep 21 '22 00:09

Matyas