Allow custom path when using engine.js preloadFile() with URL

(cherry picked from commit d373029382)
This commit is contained in:
Leon Krause 2018-03-27 11:23:38 +02:00 committed by Hein-Pieter van Braam
parent 78b44eab0a
commit 393e1ef4ee
1 changed files with 3 additions and 3 deletions

View File

@ -88,7 +88,7 @@
}); });
} }
this.preloadFile = function(pathOrBuffer, bufferFilename) { this.preloadFile = function(pathOrBuffer, destPath) {
if (pathOrBuffer instanceof ArrayBuffer) { if (pathOrBuffer instanceof ArrayBuffer) {
pathOrBuffer = new Uint8Array(pathOrBuffer); pathOrBuffer = new Uint8Array(pathOrBuffer);
@ -97,14 +97,14 @@
} }
if (pathOrBuffer instanceof Uint8Array) { if (pathOrBuffer instanceof Uint8Array) {
preloadedFiles.push({ preloadedFiles.push({
path: bufferFilename, path: destPath,
buffer: pathOrBuffer buffer: pathOrBuffer
}); });
return Promise.resolve(); return Promise.resolve();
} else if (typeof pathOrBuffer === 'string') { } else if (typeof pathOrBuffer === 'string') {
return loadPromise(pathOrBuffer, preloadProgressTracker).then(function(xhr) { return loadPromise(pathOrBuffer, preloadProgressTracker).then(function(xhr) {
preloadedFiles.push({ preloadedFiles.push({
path: pathOrBuffer, path: destPath || pathOrBuffer,
buffer: xhr.response buffer: xhr.response
}); });
}); });