Regarding the usage of bumpTexture

Regarding the usage of bumpTexture

When I ran the following script, the bump file did not seem to be applied, unlike the display when I set the bump in Shapespark. is there a mistake in the usage of the API?

var viewer = new WALK.getViewer();
viewer.setAllMaterialsEditable();
var oBump = document.createElement(“img”);
oBump.setAttribute(‘src’, ‘https://xxxx.com/xxxx.jpg’);
oBump.setAttribute(‘alt’, ‘noImg’); oBump;
oBump.style.display = “none”;
oBump.setAttribute(‘crossorigin’, ‘anonymous’);
var bumptexture = viewer.createTextureFromHtmlImage(oBump, hasAlpha=false);
var material = viewer.findMaterial(‘AAAA’);
material.bumpTexture = bumptexture;
material.bumpScale = 0.01;
material.setUniforms();
viewer.requestFrame();

var material = viewer.findMaterial(‘AAAA’);
I want to set only the material found by findMaterial.
Thank you in advance for your help.

Finding materials and setting textures works only after the scene is loaded, so you need to delay this code like this:

Viewer.onSceneReadyToDisplay(function() {
    var material = viewer.findMaterial(‘AAAA’);
    material.bumpTexture = bumptexture;
    material.bumpScale = 0.01;
    material.setUniforms();
    viewer.requestFrame();
});