import type * as THREE from 'three'; /** * Return a texture flipped left/right so it reads correctly when viewed from * behind (the back face). The back cap maps with the same planar UVs as the * front, so without a flip the back appears mirrored. * * The source texture is cloned so the transform doesn't leak into other meshes * that share the same texture (drei caches textures globally by URL). */ export function flipTexture(texture: THREE.Texture): THREE.Texture { const tex = texture.clone(); // Negate repeat.x and shift offset.x by one full repeat so the visible // region stays in the same place while mirrored. After negation // `repeat.x` is `-rx`, so subtracting it adds `rx` to the offset. tex.repeat.x = -tex.repeat.x; tex.offset.x -= tex.repeat.x; return tex; }