|
@@ -47,7 +47,6 @@ import {
|
|
|
PointsMaterial,
|
|
|
PropertyBinding,
|
|
|
QuaternionKeyframeTrack,
|
|
|
- RGBAFormat,
|
|
|
RGBFormat,
|
|
|
RepeatWrapping,
|
|
|
Skeleton,
|
|
@@ -1372,11 +1371,6 @@ var GLTFLoader = ( function () {
|
|
|
BLEND: 'BLEND'
|
|
|
};
|
|
|
|
|
|
- var MIME_TYPE_FORMATS = {
|
|
|
- 'image/png': RGBAFormat,
|
|
|
- 'image/jpeg': RGBFormat
|
|
|
- };
|
|
|
-
|
|
|
/* UTILITY FUNCTIONS */
|
|
|
|
|
|
function resolveURL( url, path ) {
|
|
@@ -2217,6 +2211,9 @@ var GLTFLoader = ( function () {
|
|
|
|
|
|
var sourceURI = source.uri;
|
|
|
var isObjectURL = false;
|
|
|
+ var hasAlpha = true;
|
|
|
+
|
|
|
+ if ( source.mimeType === 'image/jpeg' ) hasAlpha = false;
|
|
|
|
|
|
if ( source.bufferView !== undefined ) {
|
|
|
|
|
@@ -2224,6 +2221,13 @@ var GLTFLoader = ( function () {
|
|
|
|
|
|
sourceURI = parser.getDependency( 'bufferView', source.bufferView ).then( function ( bufferView ) {
|
|
|
|
|
|
+ if ( source.mimeType === 'image/png' ) {
|
|
|
+
|
|
|
+ // https://en.wikipedia.org/wiki/Portable_Network_Graphics#File_header
|
|
|
+ hasAlpha = new DataView( bufferView, 25, 1 ).getUint8( 0, false ) === 6;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
isObjectURL = true;
|
|
|
var blob = new Blob( [ bufferView ], { type: source.mimeType } );
|
|
|
sourceURI = URL.createObjectURL( blob );
|
|
@@ -2267,12 +2271,8 @@ var GLTFLoader = ( function () {
|
|
|
|
|
|
if ( textureDef.name ) texture.name = textureDef.name;
|
|
|
|
|
|
- // Ignore unknown mime types, like DDS files.
|
|
|
- if ( source.mimeType in MIME_TYPE_FORMATS ) {
|
|
|
-
|
|
|
- texture.format = MIME_TYPE_FORMATS[ source.mimeType ];
|
|
|
-
|
|
|
- }
|
|
|
+ // When there is definitely no alpha channel in the texture, set RGBFormat to save space.
|
|
|
+ if ( ! hasAlpha ) texture.format = RGBFormat;
|
|
|
|
|
|
var samplers = json.samplers || {};
|
|
|
var sampler = samplers[ textureDef.sampler ] || {};
|
|
@@ -2306,22 +2306,6 @@ var GLTFLoader = ( function () {
|
|
|
|
|
|
return this.getDependency( 'texture', mapDef.index ).then( function ( texture ) {
|
|
|
|
|
|
- if ( ! texture.isCompressedTexture ) {
|
|
|
-
|
|
|
- switch ( mapName ) {
|
|
|
-
|
|
|
- case 'aoMap':
|
|
|
- case 'emissiveMap':
|
|
|
- case 'metalnessMap':
|
|
|
- case 'normalMap':
|
|
|
- case 'roughnessMap':
|
|
|
- texture.format = RGBFormat;
|
|
|
- break;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
// Materials sample aoMap from UV set 1 and other maps from UV set 0 - this can't be configured
|
|
|
// However, we will copy UV set 0 to UV set 1 on demand for aoMap
|
|
|
if ( mapDef.texCoord !== undefined && mapDef.texCoord != 0 && ! ( mapName === 'aoMap' && mapDef.texCoord == 1 ) ) {
|