Skip to content

Instantly share code, notes, and snippets.

@ngokevin
Created September 14, 2018 23:40
Show Gist options
  • Save ngokevin/e10ae7741919e7795c27ff5318876e70 to your computer and use it in GitHub Desktop.
Save ngokevin/e10ae7741919e7795c27ff5318876e70 to your computer and use it in GitHub Desktop.
uv scrolling
this.originalUvs = JSON.parse(JSON.stringify(this.geometry.faceVertexUvs[0]));
this.uvs = this.geometry.faceVertexUvs[0];
this.uvs.forEach(face => {
indices.forEach(i => {
let uv = face[i];
uv.y += 0.00075;
if (uv.y > 1) {
needsReset = true;
return;
}
this.geometry.uvsNeedUpdate = true;
});
});
if (needsReset) {
copyArrays(this.uvs, this.originalUvs);
this.geometry.uvsNeedUpdate = true;
}
}
function copyArrays (dest, src) {
src.forEach((item, i) => {
item.forEach((uv, j) => {
dest[i][j].x = uv.x;
dest[i][j].y = uv.y;
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment