@@ -23,6 +23,7 @@ THREE.BasisTextureLoader = function ( manager ) {
2323 this . workerNextTaskID = 1 ;
2424 this . workerSourceURL = '' ;
2525 this . workerConfig = null ;
26+
2627} ;
2728
2829THREE . BasisTextureLoader . taskCache = new WeakMap ( ) ;
@@ -104,7 +105,7 @@ THREE.BasisTextureLoader.prototype = Object.assign( Object.create( THREE.Loader.
104105 /** Low-level transcoding API, exposed for use by THREE.KTX2Loader. */
105106 parseInternalAsync : function ( options ) {
106107
107- var { levels, hasAlpha , basisFormat } = options ;
108+ var { levels } = options ;
108109
109110 var buffers = new Set ( ) ;
110111
@@ -154,8 +155,6 @@ THREE.BasisTextureLoader.prototype = Object.assign( Object.create( THREE.Loader.
154155 } )
155156 . then ( ( message ) => {
156157
157- var config = this . workerConfig ;
158-
159158 var { mipmaps, width, height, format } = message ;
160159
161160 var texture = new THREE . CompressedTexture ( mipmaps , width , height , format , THREE . UnsignedByteType ) ;
@@ -221,9 +220,9 @@ THREE.BasisTextureLoader.prototype = Object.assign( Object.create( THREE.Loader.
221220
222221 var body = [
223222 '/* constants */' ,
224- 'var _EngineFormat = ' + JSON . stringify ( BasisTextureLoader . EngineFormat ) ,
225- 'var _TranscoderFormat = ' + JSON . stringify ( BasisTextureLoader . TranscoderFormat ) ,
226- 'var _BasisFormat = ' + JSON . stringify ( BasisTextureLoader . BasisFormat ) ,
223+ 'var _EngineFormat = ' + JSON . stringify ( THREE . BasisTextureLoader . EngineFormat ) ,
224+ 'var _TranscoderFormat = ' + JSON . stringify ( THREE . BasisTextureLoader . TranscoderFormat ) ,
225+ 'var _BasisFormat = ' + JSON . stringify ( THREE . BasisTextureLoader . BasisFormat ) ,
227226 '/* basis_transcoder.js */' ,
228227 jsContent ,
229228 '/* worker */' ,
@@ -430,7 +429,7 @@ THREE.BasisTextureLoader.BasisWorker = function () {
430429
431430 }
432431
433- function transcodeLowLevel ( taskConfig ) {
432+ function transcodeLowLevel ( taskConfig ) {
434433
435434 var { basisFormat, width, height, hasAlpha } = taskConfig ;
436435
@@ -517,7 +516,7 @@ THREE.BasisTextureLoader.BasisWorker = function () {
517516 hasAlpha ,
518517 false ,
519518 0 , 0 ,
520- - 1 , - 1
519+ - 1 , - 1
521520 ) ;
522521
523522 assert ( ok , 'THREE.BasisTextureLoader: transcodeUASTCImage() failed for level ' + level . index + '.' ) ;
@@ -611,64 +610,72 @@ THREE.BasisTextureLoader.BasisWorker = function () {
611610 var FORMAT_OPTIONS = [
612611 {
613612 if : 'astcSupported' ,
614- basisFormat : [ BasisFormat . UASTC_4x4 ] ,
615- transcoderFormat : [ TranscoderFormat . ASTC_4x4 , TranscoderFormat . ASTC_4x4 ] ,
616- engineFormat : [ EngineFormat . RGBA_ASTC_4x4_Format , EngineFormat . RGBA_ASTC_4x4_Format ] ,
613+ basisFormat : [ BasisFormat . UASTC_4x4 ] ,
614+ transcoderFormat : [ TranscoderFormat . ASTC_4x4 , TranscoderFormat . ASTC_4x4 ] ,
615+ engineFormat : [ EngineFormat . RGBA_ASTC_4x4_Format , EngineFormat . RGBA_ASTC_4x4_Format ] ,
617616 priorityETC1S : Infinity ,
618617 priorityUASTC : 1 ,
619618 needsPowerOfTwo : false ,
620619 } ,
621620 {
622621 if : 'bptcSupported' ,
623- basisFormat : [ BasisFormat . ETC1S , BasisFormat . UASTC_4x4 ] ,
624- transcoderFormat : [ TranscoderFormat . BC7_M5 , TranscoderFormat . BC7_M5 ] ,
625- engineFormat : [ EngineFormat . RGBA_BPTC_Format , EngineFormat . RGBA_BPTC_Format ] ,
622+ basisFormat : [ BasisFormat . ETC1S , BasisFormat . UASTC_4x4 ] ,
623+ transcoderFormat : [ TranscoderFormat . BC7_M5 , TranscoderFormat . BC7_M5 ] ,
624+ engineFormat : [ EngineFormat . RGBA_BPTC_Format , EngineFormat . RGBA_BPTC_Format ] ,
626625 priorityETC1S : 3 ,
627626 priorityUASTC : 2 ,
628627 needsPowerOfTwo : false ,
629628 } ,
630629 {
631630 if : 'dxtSupported' ,
632- basisFormat : [ BasisFormat . ETC1S , BasisFormat . UASTC_4x4 ] ,
633- transcoderFormat : [ TranscoderFormat . BC1 , TranscoderFormat . BC3 ] ,
634- engineFormat : [ EngineFormat . RGB_S3TC_DXT1_Format , EngineFormat . RGBA_S3TC_DXT5_Format ] ,
631+ basisFormat : [ BasisFormat . ETC1S , BasisFormat . UASTC_4x4 ] ,
632+ transcoderFormat : [ TranscoderFormat . BC1 , TranscoderFormat . BC3 ] ,
633+ engineFormat : [ EngineFormat . RGB_S3TC_DXT1_Format , EngineFormat . RGBA_S3TC_DXT5_Format ] ,
635634 priorityETC1S : 4 ,
636635 priorityUASTC : 5 ,
637636 needsPowerOfTwo : false ,
638637 } ,
639638 {
640639 if : 'etc2Supported' ,
641- basisFormat : [ BasisFormat . ETC1S , BasisFormat . UASTC_4x4 ] ,
642- transcoderFormat : [ TranscoderFormat . ETC1 , TranscoderFormat . ETC2 ] ,
643- engineFormat : [ EngineFormat . RGB_ETC2_Format , EngineFormat . RGBA_ETC2_EAC_Format ] ,
640+ basisFormat : [ BasisFormat . ETC1S , BasisFormat . UASTC_4x4 ] ,
641+ transcoderFormat : [ TranscoderFormat . ETC1 , TranscoderFormat . ETC2 ] ,
642+ engineFormat : [ EngineFormat . RGB_ETC2_Format , EngineFormat . RGBA_ETC2_EAC_Format ] ,
644643 priorityETC1S : 1 ,
645644 priorityUASTC : 3 ,
646645 needsPowerOfTwo : false ,
647646 } ,
648647 {
649648 if : 'etc1Supported' ,
650- basisFormat : [ BasisFormat . ETC1S , BasisFormat . UASTC_4x4 ] ,
651- transcoderFormat : [ TranscoderFormat . ETC1 , TranscoderFormat . ETC1 ] ,
652- engineFormat : [ EngineFormat . RGB_ETC1_Format , EngineFormat . RGB_ETC1_Format ] ,
649+ basisFormat : [ BasisFormat . ETC1S , BasisFormat . UASTC_4x4 ] ,
650+ transcoderFormat : [ TranscoderFormat . ETC1 , TranscoderFormat . ETC1 ] ,
651+ engineFormat : [ EngineFormat . RGB_ETC1_Format , EngineFormat . RGB_ETC1_Format ] ,
653652 priorityETC1S : 2 ,
654653 priorityUASTC : 4 ,
655654 needsPowerOfTwo : false ,
656655 } ,
657656 {
658657 if : 'pvrtcSupported' ,
659- basisFormat : [ BasisFormat . ETC1S , BasisFormat . UASTC_4x4 ] ,
660- transcoderFormat : [ TranscoderFormat . PVRTC1_4_RGB , TranscoderFormat . PVRTC1_4_RGBA ] ,
661- engineFormat : [ EngineFormat . RGB_PVRTC_4BPPV1_Format , EngineFormat . RGBA_PVRTC_4BPPV1_Format ] ,
658+ basisFormat : [ BasisFormat . ETC1S , BasisFormat . UASTC_4x4 ] ,
659+ transcoderFormat : [ TranscoderFormat . PVRTC1_4_RGB , TranscoderFormat . PVRTC1_4_RGBA ] ,
660+ engineFormat : [ EngineFormat . RGB_PVRTC_4BPPV1_Format , EngineFormat . RGBA_PVRTC_4BPPV1_Format ] ,
662661 priorityETC1S : 5 ,
663662 priorityUASTC : 6 ,
664663 needsPowerOfTwo : true ,
665664 } ,
666665 ] ;
667666
668- var ETC1S_OPTIONS = FORMAT_OPTIONS . sort ( function ( a , b ) { return a . priorityETC1S - b . priorityETC1S ; } ) ;
669- var UASTC_OPTIONS = FORMAT_OPTIONS . sort ( function ( a , b ) { return a . priorityUASTC - b . priorityUASTC ; } ) ;
667+ var ETC1S_OPTIONS = FORMAT_OPTIONS . sort ( function ( a , b ) {
668+
669+ return a . priorityETC1S - b . priorityETC1S ;
670+
671+ } ) ;
672+ var UASTC_OPTIONS = FORMAT_OPTIONS . sort ( function ( a , b ) {
673+
674+ return a . priorityUASTC - b . priorityUASTC ;
675+
676+ } ) ;
670677
671- function getTranscoderFormat ( basisFormat , width , height , hasAlpha ) {
678+ function getTranscoderFormat ( basisFormat , width , height , hasAlpha ) {
672679
673680 var transcoderFormat ;
674681 var engineFormat ;
@@ -699,25 +706,25 @@ THREE.BasisTextureLoader.BasisWorker = function () {
699706
700707 }
701708
702- function assert ( ok , message ) {
709+ function assert ( ok , message ) {
703710
704711 if ( ! ok ) throw new Error ( message ) ;
705712
706713 }
707714
708- function getWidthInBlocks ( transcoderFormat , width ) {
715+ function getWidthInBlocks ( transcoderFormat , width ) {
709716
710717 return Math . ceil ( width / BasisModule . getFormatBlockWidth ( transcoderFormat ) ) ;
711718
712719 }
713720
714- function getHeightInBlocks ( transcoderFormat , height ) {
721+ function getHeightInBlocks ( transcoderFormat , height ) {
715722
716723 return Math . ceil ( height / BasisModule . getFormatBlockHeight ( transcoderFormat ) ) ;
717724
718725 }
719726
720- function getTranscodedImageByteLength ( transcoderFormat , width , height ) {
727+ function getTranscodedImageByteLength ( transcoderFormat , width , height ) {
721728
722729 var blockByteLength = BasisModule . getBytesPerBlockOrPixel ( transcoderFormat ) ;
723730
@@ -745,7 +752,7 @@ THREE.BasisTextureLoader.BasisWorker = function () {
745752
746753 }
747754
748- function isPowerOfTwo ( value ) {
755+ function isPowerOfTwo ( value ) {
749756
750757 if ( value <= 2 ) return true ;
751758
0 commit comments