Skip to content

Instantly share code, notes, and snippets.

@RenaudRohlinger
Created March 30, 2020 06:15
Show Gist options
  • Save RenaudRohlinger/53a11736401dd54c0a235003bda8d105 to your computer and use it in GitHub Desktop.
Save RenaudRohlinger/53a11736401dd54c0a235003bda8d105 to your computer and use it in GitHub Desktop.
function setInstancedMeshPositions(mesh, section) {
for ( var i = 0; i < mesh.count; i ++ ) {
var xStaticPosition = -sectionWidth * (i - 1);
var xSectionPosition = sectionWidth * section;
var x = xStaticPosition + xSectionPosition;
dummy.position.set(x, 0, 0);
dummy.updateMatrix();
mesh.setMatrixAt( i, dummy.matrix );
}
mesh.instanceMatrix.needsUpdate = true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment