-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- WIP: Updating jsdoc TransferableUtils: - split into TransferableUtils and MeshMessageStructure to have a now have a formal definition of what should is transferred. ResourceDescriptor & FileLoaderBufferAsync (renamed from FileLoadingExecutor) - Reviewed, reworked and added jsdoc
- Loading branch information
Showing
7 changed files
with
431 additions
and
314 deletions.
There are no files selected for viewing
This file contains 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 file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* @author Kai Salmen / https://kaisalmen.de | ||
* Development repository: https://github.com/kaisalmen/WWOBJLoader | ||
*/ | ||
|
||
import { | ||
FileLoader | ||
} from "../../../../../build/three.module.js"; | ||
|
||
/** | ||
* Extension of {@link FileLoader} that configures "arraybuffer" as default response type and carries a specific | ||
* onProgress function for {@link FileLoader#loadAsync}. | ||
*/ | ||
class FileLoaderBufferAsync extends FileLoader { | ||
|
||
constructor() { | ||
super(); | ||
this.setResponseType( 'arraybuffer' ); | ||
} | ||
|
||
/** | ||
* Load the resource defined in the first argument. | ||
* | ||
* @param {URL} url | ||
* @param {Function} [onProgress] | ||
* @return {Promise<unknown>} | ||
*/ | ||
loadFileAsync ( url, onProgress ) { | ||
let numericalValueRef = 0; | ||
let numericalValue = 0; | ||
function scopedOnReportProgress( event ) { | ||
|
||
if ( ! event.lengthComputable ) return; | ||
numericalValue = event.loaded / event.total; | ||
if ( numericalValue > numericalValueRef ) { | ||
|
||
numericalValueRef = numericalValue; | ||
let output = 'Download of "' + url + '": ' + ( numericalValue * 100 ).toFixed( 2 ) + '%'; | ||
if ( onProgress !== undefined && onProgress !== null ) { | ||
|
||
onProgress( { | ||
detail: { | ||
type: 'progressLoad', | ||
text: output, | ||
numericalValue: numericalValue | ||
} | ||
} ); | ||
|
||
} | ||
} | ||
} | ||
return this.loadAsync( url.href, scopedOnReportProgress ); | ||
|
||
} | ||
|
||
} | ||
|
||
export { FileLoaderBufferAsync } |
Oops, something went wrong.