I am currently working on an application to modify minecraft models. To display the drawn texture mapped on the 3D player model, I am using ThreeJS. However, I'm facing a challenge related to changing the texture size.
Initially, the texture is mapped on the model like this. When I change the texture height to 64, it transforms into this.
The texture creation process looks like this:
/* Texture */
var texture = new THREE.Texture(canvas);
texture.minFilter = texture.magFilter = THREE.NearestFilter;
Here, the variable canvas
refers to HTMLCanvasElement. Whenever the content of the canvas changes, I refresh the texture using the following steps:
this.skin.render(canvas.getContext("2d"), this.skin.w, this.skin.h);
this.limbs.forEach(function (limb) {
limb.mapUV(self.skin.w, self.skin.h);
});
this.material.map.needsUpdate = true;
this.material.needsUpdate = true;
In this code snippet, this.material
represents a double sided transparent material with an attached texture. The UV's appear to be correct.
In a previous application, I solved a similar issue by recreating the entire mesh. However, in this scenario, that approach seems costly. How can I resolve this issue? It appears as though the texture might be cached or something similar. If my assumption is correct, how can I clear the cache?
Thank you for your attention!
P.S.: Apologies for not being able to share images due to restrictions on my reputation.