فهرست منبع

Merge pull request #14768 from donmccurdy/feat-image-mimetype

GLTFLoader: Use mimetype to set texture format, if set.
Mr.doob 7 سال پیش
والد
کامیت
bced02a8c8
1فایلهای تغییر یافته به همراه12 افزوده شده و 0 حذف شده
  1. 12 0
      examples/js/loaders/GLTFLoader.js

+ 12 - 0
examples/js/loaders/GLTFLoader.js

@@ -1139,6 +1139,11 @@ THREE.GLTFLoader = ( function () {
 		BLEND: 'BLEND'
 	};
 
+	var MIME_TYPE_FORMATS = {
+		'image/png': THREE.RGBAFormat,
+		'image/jpeg': THREE.RGBFormat
+	};
+
 	/* UTILITY FUNCTIONS */
 
 	function resolveURL( url, path ) {
@@ -2042,6 +2047,13 @@ THREE.GLTFLoader = ( function () {
 
 			if ( textureDef.name !== undefined ) 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 ];
+
+			}
+
 			var samplers = json.samplers || {};
 			var sampler = samplers[ textureDef.sampler ] || {};