How i can create interactive Texture Change

Hello, I have seen this product “BMW i8 - PLAYCANVAS” changing its texture in run time. I want to learn how can I do so.

Please help me!

This example shows how to change the material of an entity by clicking the button. Material change occurs in the ui.js script starting at 49 lines.

var obj ='chamferbox');
if (obj && obj.model && obj.model.model) {
    var material = obj.model.model.meshInstances[0].material;
    if (material) {
        material.diffuse.set(Math.random(), Math.random(), Math.random());

This is where the entity is accessed, checked for the existence of a component of the model for the entity and the material. If the condition is successful, then the generation and assignment of a new random diffuse color occurs. Other properties for color maps can be found here.

1 Like