Created
September 14, 2018 23:40
-
-
Save ngokevin/e10ae7741919e7795c27ff5318876e70 to your computer and use it in GitHub Desktop.
uv scrolling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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