From 860af3c012915be534f8a5c37d745e2dff339e04 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Tue, 10 May 2022 11:45:35 +0900 Subject: [PATCH] r140 (bis) (bis) --- editor/sw.js | 2 +- examples/js/exporters/GLTFExporter.js | 18 ++++++++++++++++-- package.json | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/editor/sw.js b/editor/sw.js index a25a79e598d272..9df579af4580bf 100644 --- a/editor/sw.js +++ b/editor/sw.js @@ -1,4 +1,4 @@ -// r140.1 +// r140.2 const cacheName = 'threejs-editor'; diff --git a/examples/js/exporters/GLTFExporter.js b/examples/js/exporters/GLTFExporter.js index d87ed92a398b72..6d3b4ff8f0cd0e 100644 --- a/examples/js/exporters/GLTFExporter.js +++ b/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 } ); } diff --git a/package.json b/package.json index ca7535ce8d4ca3..482d1d428b45df 100644 --- a/package.json +++ b/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",