Skip to content

Commit

Permalink
Added parse method to KTX2Loader for direct buffer processing (mrdoob…
Browse files Browse the repository at this point in the history
  • Loading branch information
laddish authored and brunosimon committed Jul 25, 2024
1 parent 5cbb0e8 commit c441b6b
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions examples/jsm/loaders/KTX2Loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,22 +251,34 @@ class KTX2Loader extends Loader {

loader.load( url, ( buffer ) => {

// Check for an existing task using this buffer. A transferred buffer cannot be transferred
// again from this thread.
if ( _taskCache.has( buffer ) ) {
this.parse( buffer, onLoad, onError);

}, onProgress, onError );

}

parse( buffer, onLoad, onError ) {

if ( this.workerConfig === null ) {

throw new Error( 'THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.' );

}

// Check for an existing task using this buffer. A transferred buffer cannot be transferred
// again from this thread.
if ( _taskCache.has( buffer ) ) {

const cachedTask = _taskCache.get( buffer );

return cachedTask.promise.then( onLoad ).catch( onError );

}
}

this._createTexture( buffer )
this._createTexture( buffer )
.then( ( texture ) => onLoad ? onLoad( texture ) : null )
.catch( onError );

}, onProgress, onError );

}

_createTextureFrom( transcodeResult, container ) {
Expand Down

0 comments on commit c441b6b

Please sign in to comment.