The BufferGeometry whose UV coordinates will be updated
The material that must contain a SharedStageTexture
The rectangular area of the texture to display
// Create geometry and material
const geometry = new PlaneGeometry(1, 1);
const material = new MeshBasicMaterial({ map: sharedTexture });
// Define the area to display (256x256 pixels at position 0,0)
const textureArea = { x: 0, y: 0, width: 256, height: 256 };
// Update UV coordinates
updateUVAttribute(geometry, material, textureArea);
// Create mesh
const mesh = new Mesh(geometry, material);
Updates the UV attributes of a geometry to display a specific area of the shared texture.
This utility function modifies the UV coordinates of a BufferGeometry to map a rectangular area of the SharedStageTexture to the geometry's surface. The UV coordinates are calculated automatically and applied to the geometry's UV attribute.
Important: This function assumes the geometry has a standard quad UV layout with 4 vertices.