Skip to content

ExtrudeGeometry: Custom uv coordinates examples. #31312

Closed
@linbingquan

Description

@linbingquan

Description

Passing side parameters, options.UVGenerator.generateTopUV should make it more convenient to customize uv coordinates.

There might be a simpler way, such as judging the position of the array index to determine which side it is.
If there are any good methods, please tell me. Thank you.

So far, I still haven't figured out how generateSideWallUV works...

It would be better if there were examples regarding the use of options.UVGenerator.generateTopUV or options.UVGenerator.generateSideWallUV.

Solution

It shouldn't be the best solution

diff --git a/src/geometries/ExtrudeGeometry.js b/src/geometries/ExtrudeGeometry.js
index 242a529580..807bcde78f 100644
--- a/src/geometries/ExtrudeGeometry.js
+++ b/src/geometries/ExtrudeGeometry.js
@@ -583,7 +583,7 @@ class ExtrudeGeometry extends BufferGeometry {
 					for ( let i = 0; i < flen; i ++ ) {
 
 						const face = faces[ i ];
-						f3( face[ 2 ] + offset, face[ 1 ] + offset, face[ 0 ] + offset );
+						f3( face[ 2 ] + offset, face[ 1 ] + offset, face[ 0 ] + offset, 'bottom' );
 
 					}
 
@@ -595,7 +595,7 @@ class ExtrudeGeometry extends BufferGeometry {
 					for ( let i = 0; i < flen; i ++ ) {
 
 						const face = faces[ i ];
-						f3( face[ 0 ] + offset, face[ 1 ] + offset, face[ 2 ] + offset );
+						f3( face[ 0 ] + offset, face[ 1 ] + offset, face[ 2 ] + offset, 'top' );
 
 					}
 
@@ -606,7 +606,7 @@ class ExtrudeGeometry extends BufferGeometry {
 					for ( let i = 0; i < flen; i ++ ) {
 
 						const face = faces[ i ];
-						f3( face[ 2 ], face[ 1 ], face[ 0 ] );
+						f3( face[ 2 ], face[ 1 ], face[ 0 ], 'bottom' );
 
 					}
 
@@ -615,7 +615,7 @@ class ExtrudeGeometry extends BufferGeometry {
 					for ( let i = 0; i < flen; i ++ ) {
 
 						const face = faces[ i ];
-						f3( face[ 0 ] + vlen * steps, face[ 1 ] + vlen * steps, face[ 2 ] + vlen * steps );
+						f3( face[ 0 ] + vlen * steps, face[ 1 ] + vlen * steps, face[ 2 ] + vlen * steps, 'top' );
 
 					}
 
@@ -689,14 +689,14 @@ class ExtrudeGeometry extends BufferGeometry {
 			}
 
 
-			function f3( a, b, c ) {
+			function f3( a, b, c, side ) {
 
 				addVertex( a );
 				addVertex( b );
 				addVertex( c );
 
 				const nextIndex = verticesArray.length / 3;
-				const uvs = uvgen.generateTopUV( scope, verticesArray, nextIndex - 3, nextIndex - 2, nextIndex - 1 );
+				const uvs = uvgen.generateTopUV( scope, verticesArray, nextIndex - 3, nextIndex - 2, nextIndex - 1, side );
 
 				addUV( uvs[ 0 ] );
 				addUV( uvs[ 1 ] );
@@ -805,7 +805,7 @@ class ExtrudeGeometry extends BufferGeometry {
 
 const WorldUVGenerator = {
 
-	generateTopUV: function ( geometry, vertices, indexA, indexB, indexC ) {
+	generateTopUV: function ( geometry, vertices, indexA, indexB, indexC, side ) {
 
 		const a_x = vertices[ indexA * 3 ];
 		const a_y = vertices[ indexA * 3 + 1 ];

Alternatives

I can modify the reverse texture relatively easily and it won't be mirrored.

Before After
Image Image

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions