I load a texture from an external server (via JSON). This is how:
if(imageSrc){
var shape = clone.findByName("imageShape");
var material = shape.model.meshInstances[0].material;
var newMaterial = material.clone();
this.app.assets.loadFromUrl(imageSrc, "texture", function (err, asset) {
asset.ready(function (asset) {
var texture = asset._resources[0];
newMaterial.diffuseMap = texture;
shape.model.meshInstances[0].material = newMaterial;
newMaterial.update();
});
});
}
Works fine but…!
…but the texture is displayed in a weird way. If I upload the same texture into the asset manager and connect it to the diffuse channel it looks like it should.
I think the issue is that most like the texture you load in code is missing some standard properties, which are prefilled when you import it in the editor. Properties like filtering and UV addressing.
Take a look at this example on how to set those properties in code, this might resolve your issue:
Hi @Leonidas, you’re right. It seems to be a Safari problem. I’m using Safari 13.0.4 on MacOS 10.15.2. Firefox and Chrome are working fine.
Has anyone from Playcanvas staff a solution for that?
Yes, that’s it. Activation of WebGL 2 in Safari (developer / experimental functions) solve the problem (for me) but not for my audition and the rest of the world.
Ok, it has something to to with so called “Power of two” images. If I use an image of the playcanvas example it works. https://s.gravatar.com/avatar/9cabe6ef56706fc096eb29d33e1846ac?s=512
So I have only to find out what a power of two image is and how to create it. is it the size (512 x512)?
I’ll write it down here as soon as I’ve found it out.