transformUv method
Vector2
transformUv(
- Vector2 uv
Implementation
Vector2 transformUv(Vector2 uv) {
if (mapping != UVMapping) return uv;
uv.applyMatrix3(matrix);
if (uv.x < 0 || uv.x > 1) {
switch (wrapS) {
case RepeatWrapping:
uv.x = uv.x - uv.x.floor();
break;
case ClampToEdgeWrapping:
uv.x = uv.x < 0 ? 0 : 1;
break;
case MirroredRepeatWrapping:
if((uv.x.floor().abs() % 2) == 1) {
uv.x = uv.x.ceil() - uv.x;
} else {
uv.x = uv.x - uv.x.floor();
}
break;
}
}
if (uv.y < 0 || uv.y > 1) {
switch (wrapT) {
case RepeatWrapping:
uv.y = uv.y - uv.y.floor();
break;
case ClampToEdgeWrapping:
uv.y = uv.y < 0 ? 0 : 1;
break;
case MirroredRepeatWrapping:
if((uv.y.floor().abs() % 2) == 1) {
uv.y = uv.y.ceil() - uv.y;
} else {
uv.y = uv.y - uv.y.floor();
}
break;
}
}
if (flipY) {
uv.y = 1 - uv.y;
}
return uv;
}