Fix bug when last line is not empty

This commit is contained in:
Thomas Forgione 2021-10-14 10:01:13 +02:00
parent 5fe58b2eca
commit ad14be7b75
3 changed files with 7 additions and 1 deletions

View File

@ -5,7 +5,7 @@ animate();
function init() { function init() {
let url = (document.URL.split('?')[1] || "exemple/suzanne.obja"); let url = (document.URL.split('?')[1] || "example/suzanne.obja");
loader = new Loader(url, 1024, 20); loader = new Loader(url, 1024, 20);
loader.start(function(elements) { loader.start(function(elements) {

View File

@ -196,6 +196,9 @@ class Loader {
let upperBound = Math.min(this.currentByte + this.chunkSize, this.dataLength); let upperBound = Math.min(this.currentByte + this.chunkSize, this.dataLength);
if (upperBound <= this.currentByte) { if (upperBound <= this.currentByte) {
if (this.remainder !== "") {
callback([parseLine(this.remainder, 0)]);
}
return; return;
} }

View File

@ -196,6 +196,9 @@ class Loader {
let upperBound = Math.min(this.currentByte + this.chunkSize, this.dataLength); let upperBound = Math.min(this.currentByte + this.chunkSize, this.dataLength);
if (upperBound <= this.currentByte) { if (upperBound <= this.currentByte) {
if (this.remainder !== "") {
callback([parseLine(this.remainder, 0)]);
}
return; return;
} }