Different wallpaper on each face of the cube

Hello
How the hell would I set the wallpaper different for each face of the cube?
There is no such thing as faces in version 125.
I am looking and looking and I cannot think of anything.

Just for clarification: Do you want to apply a texture per side of the cube or per triangle? Unfortunately, the term cube face has a different semantic depending on the developer.

I use.
geometry.setIndex ();
To save on creating vertices.
I want to be able to assign a different wallpaper to each wall.
I turn off some walls and want to be able to dynamically decide on the wallpaper.
As now it has been solved in version 125 because it is not very transparent and not intuitive.

Okay, I thought would work with BoxGeometry. In this case, you can just apply an array of materials where each material is mapped to one side of the box.

If you generate the geometry by yourself, you have to generate groups data in order to support multi-materials. The idea is to use the addGroup() method to specify what parts of the geometry should be rendered by a given material. Exemplary calls look like so:

geometry.addGroup( 0, 3, 0 );
geometry.addGroup( 3, 3, 1 );

Since you working with an indexed geometry, the first two parameters refer to indices in your case. The third parameter is the material index. The above code means the first triangle (defined by the first three indices in your index buffer) is rendered with the first material and the second triangle is rendered with the second material.

1 Like