Skip to content

Commit 1e210ac

Browse files
committed
USDZExporter: Improved resizing code.
1 parent 39efa38 commit 1e210ac

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

examples/jsm/exporters/USDZExporter.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,11 @@ async function imgToU8( image ) {
8383
( typeof OffscreenCanvas !== 'undefined' && image instanceof OffscreenCanvas ) ||
8484
( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) {
8585

86+
const scale = 1024 / Math.max( image.width, image.height );
87+
8688
const canvas = document.createElement( 'canvas' );
87-
canvas.width = Math.min( 1024, image.width );
88-
canvas.height = Math.min( 1024, image.height );
89+
canvas.width = image.width * Math.min( 1, scale );
90+
canvas.height = image.height * Math.min( 1, scale );
8991

9092
const context = canvas.getContext( '2d' );
9193
context.drawImage( image, 0, 0, canvas.width, canvas.height );

0 commit comments

Comments
 (0)