Three.js: Possible to flip a sprite?

徘徊边缘 提交于 2021-02-07 13:25:42

问题


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.


回答1:


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




回答2:


the easiest way to flip a texture is actually to flip the texture image before uploading to the GPU.




回答3:


Just posting it as an alternative:

texture = new three60.THREE.Texture(video);
texture.repeat.set(-1, 1);
texture.offset.set( 1, 0);


来源:https://stackoverflow.com/questions/14052047/three-js-possible-to-flip-a-sprite

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!