Skip to content

Commit

Permalink
Allow to specify the Texture channel for the lightmap
Browse files Browse the repository at this point in the history
Newer three.js versions support multiple uv attributes for gltf models. This introduces the need to specify which uv attributes is the one relevant for our lightmap texture.

See mrdoob/three.js#25721
  • Loading branch information
Antonio Pisano committed Jan 12, 2024
1 parent f1bab15 commit 17259ee
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion model-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ AFRAME.registerComponent('lightmap', {
},
basis: {
default: false
},
channel: {
type: 'int',
default: 1
}
},
init() {

const src = typeof this.data.src === 'string' ? this.data.src : this.data.src.src;
const texture = new THREE.TextureLoader().load(src);
texture.flipY = false;
texture.channel = this.data.channel;
this.texture = texture;

this.el.addEventListener('object3dset', this.update.bind(this));
Expand Down Expand Up @@ -103,4 +108,4 @@ AFRAME.registerComponent('no-tonemapping', {
}
}.bind(this));
}
});
});

0 comments on commit 17259ee

Please sign in to comment.