Mr.doob 3 лет назад
Родитель
Сommit
5c6b43e94a
3 измененных файлов с 18 добавлено и 4 удалено
  1. 1 1
      editor/sw.js
  2. 16 2
      examples/js/exporters/GLTFExporter.js
  3. 1 1
      package.json

+ 1 - 1
editor/sw.js

@@ -1,4 +1,4 @@
-// r140.1
+// r140.2
 
 const cacheName = 'threejs-editor';
 

+ 16 - 2
examples/js/exporters/GLTFExporter.js

@@ -305,7 +305,7 @@
 
 		}
 
-		if ( typeof OffscreenCanvas !== 'undefined' ) {
+		if ( typeof document === 'undefined' && typeof OffscreenCanvas !== 'undefined' ) {
 
 			cachedCanvas = new OffscreenCanvas( 1, 1 );
 
@@ -1005,8 +1005,22 @@
 
 					} else {
 
+						let quality; // Blink's implementation of convertToBlob seems to default to a quality level of 100%
+						// Use the Blink default quality levels of toBlob instead so that file sizes are comparable.
+
+						if ( mimeType === 'image/jpeg' ) {
+
+							quality = 0.92;
+
+						} else if ( mimeType === 'image/webp' ) {
+
+							quality = 0.8;
+
+						}
+
 						toBlobPromise = canvas.convertToBlob( {
-							type: mimeType
+							type: mimeType,
+							quality: quality
 						} );
 
 					}

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "three",
-  "version": "0.140.1",
+  "version": "0.140.2",
   "description": "JavaScript 3D library",
   "type": "module",
   "main": "./build/three.js",