Hi,
I’m trying to attach a texture to a newly created material. This code below tells that I’m getting a texture from a JSON data I have, attached to a diffuseMap of the new material that’ll be used by the model.
I have checked that the spriteSheetData and texture are fetched just fine (the data is there, not undefined). But I get nothing to display at all. It suppose to show a gold gear, instead of dark colored plane.
I’ve tried adding the opacityMap to make sure, but it vanishes instead.
Did I miss something?
var material = new pc.PhongMaterial();
var spriteSheetData = Game.App.assets.get(this.spriteSheetData).resource[this.initialSpriteSheetID];
var texture = pc.script.app.assets.find(spriteSheetData.filename).resource;
if (!spriteSheetData)
{
throw Error("Sprite sheet data is not attached, or does not exist, or animation ID is not set.");
}
material.opacity = 1;
material.blendType = pc.BLEND_NORMAL;
material.diffuseMap = texture;
material.diffuseMapTiling.set(1 / spriteSheetData.tileX, 1 / spriteSheetData.tileY);
material.update();
this.entity.model.model.meshInstances[0].material = material;
...