Linmic
Linmic

Reputation: 791

Horizontally flip a image texture with MeshPhongMaterial in Three.js

I've tried the following with MeshBasicMaterial:

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

And it works, but only with this specific material.

I'd like to know how to do the same on either MeshLambertMaterial or MeshPhongMaterial.

UPDATED

I've created a live example here: http://jsbin.com/jecaqi/18/edit?js,output

In this example, I flipped the image texture with MeshBasicMaterial(mesh_basic) on the left side one. My purpose is to do exact the same thing on the right one with MeshPhongMaterial(mesh_phong).

Upvotes: 0

Views: 1590

Answers (1)

WestLangley
WestLangley

Reputation: 104833

If you want to horizontally flip and an image on a texture, you can do so by using the following pattern:

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

You also need to make sure that the image is a power-of-two (POT).

three.js r.71

Upvotes: 1

Related Questions