From 8499c68cb62bc3dceb9eb6c2cfb658b74ef5b481 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Fri, 18 Jun 2021 19:44:00 -0400 Subject: [PATCH] Enable ImageBitmap for external textures in Model --- CHANGES.md | 1 + Source/Scene/GltfImageLoader.js | 4 +++- Source/Scene/Model.js | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 5fa19bdf5df3..7e71d6554780 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -20,6 +20,7 @@ - Fixed broken image URL in the KML Sandcastle. [#9579](https://github.com/CesiumGS/cesium/pull/9579) - Fixed an error where the `positionToEyeEC` and `tangentToEyeMatrix` properties for custom materials were not set in `GlobeFS`. [#9597](https://github.com/CesiumGS/cesium/pull/9597) - Fixed misleading documentation in `Matrix4.inverse` and `Matrix4.inverseTransformation` that used "affine transformation" instead of "rotation and translation" specifically. [#9608](https://github.com/CesiumGS/cesium/pull/9608) +- Fixed a regression where external images in glTF models were not being loaded with `preferImageBitmap`, which caused them to decode on the main thread and cause frame rate stuttering. [#9627](https://github.com/CesiumGS/cesium/pull/9627) ##### Deprecated :hourglass_flowing_sand: diff --git a/Source/Scene/GltfImageLoader.js b/Source/Scene/GltfImageLoader.js index 85725f68c2c0..97fc97200450 100644 --- a/Source/Scene/GltfImageLoader.js +++ b/Source/Scene/GltfImageLoader.js @@ -275,7 +275,9 @@ function loadImageFromUri(resource) { return loadCRN(resource); } // Resolves to an ImageBitmap or Image - return resource.fetchImage(); + return resource.fetchImage({ + preferImageBitmap: true, + }); } /** diff --git a/Source/Scene/Model.js b/Source/Scene/Model.js index 8f5b7abb58a0..e6a266e91dc5 100644 --- a/Source/Scene/Model.js +++ b/Source/Scene/Model.js @@ -2032,7 +2032,9 @@ function parseTextures(model, context, supportsWebP) { } else if (crnRegex.test(uri)) { promise = loadCRN(imageResource); } else { - promise = imageResource.fetchImage(); + promise = imageResource.fetchImage({ + preferImageBitmap: true, + }); } promise .then(imageLoad(model, id, imageId))