Skip to content

Commit

Permalink
Fix #2510 Incorrect gltf texture export when embedding is off
Browse files Browse the repository at this point in the history
  • Loading branch information
JannisX11 committed Oct 23, 2024
1 parent eb3a98a commit c544eec
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/GLTFExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ GLTFExporter.prototype = {
* @param {Boolean} flipY before writing out the image
* @return {Integer} Index of the processed texture in the "images" array
*/
function processImage( image, format, flipY ) {
function processImage( image, format, flipY, bb_texture ) {

if ( ! cachedData.images.has( image ) ) {

Expand Down Expand Up @@ -838,8 +838,9 @@ GLTFExporter.prototype = {
}

} else {

gltfImage.uri = image.src;

gltfImage.name = bb_texture ? bb_texture.name : 'Unknown';
gltfImage.uri = bb_texture ? `${bb_texture.name.replace(/\.png$/, '')}.png` : '';

}

Expand Down Expand Up @@ -899,10 +900,12 @@ GLTFExporter.prototype = {

}

let bb_texture = Texture.all.find(tex => tex.getMaterial()?.map?.uuid == map.uuid);

var gltfTexture = {

sampler: processSampler( map ),
source: processImage( map.image, map.format, false )
source: processImage( map.image, map.format, false, bb_texture )

};

Expand Down

0 comments on commit c544eec

Please # to comment.