How to flip a Three.js texture horizontally

 ̄綄美尐妖づ 提交于 2019-12-17 16:36:34

问题


I'm making a 360 viewer, so textures are inside a cylinder. Problem is that they appear inverted horizontally.

I know about texture.flipY but I haven't found a texture.flipX on the source.

So how can I flip a texture horizontally, or along the x axis, directly in the code? (not using an image editor)


回答1:


To flip a texture horizontally, you can do the following:

texture.wrapS = THREE.RepeatWrapping;
texture.repeat.x = - 1;

As mentioned in the comments, this approach requires the texture to be a power-of-two in size.

three.js r.87




回答2:


The answer was easier than I thought.

cylinder.scale.x = -1;

And don't forget to add

material.side = THREE.DoubleSide;


来源:https://stackoverflow.com/questions/29974578/how-to-flip-a-three-js-texture-horizontally

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