I have written the below to change the texture of decal material when I click on HTML listed images. the function is working fine but decal keeping the old one only. Here all the images in HTML are coming from the database. Please guide because most of the things which want change are coming from the database. Thank you
<div> <img onclick="changeIt(this)" src="textures/marb1.jpg" width="50" height="50" style="position:absolute"/>
<img onclick="changeIt(this)" src="textures/marb2.jpg" width="50" height="50" style="position:absolute; top:100px"/>
</div>
<canvas id="renderCanvas"></canvas>
<script>
var canvas = document.getElementById("renderCanvas");
var myimage = "textures/ground.jpg";
var changeIt = function (img) { myimage = img.src; };
var engine = null;
var scene = null;
var sceneToRender = null;
var createDefaultEngine = function() { return new BABYLON.Engine(canvas, true, { preserveDrawingBuffer: true, stencil: true }); };
var delayCreateScene = function () {
....
...
....
mat.diffuseTexture = new BABYLON.Texture(myimage, scene);
................
........