Updating the scene.background using drag/drop

I would like to offer the ability for users to drag an image onto the application window and update the scene.background texture that was loaded during initialization. The ‘drop’ listener is triggered and a reasonable value (data URL) arrives as part of the event but setting texture.image.src to this URL doesn’t cause the scene background to update.

This fiddle demonstrates what I mean: https://jsfiddle.net/upg02dz3/6/ - drag an image from a folder or your desktop onto the image.

I suspect I need to set a needsUpdate boolean somewhere to cause an internal update but I haven’t been able to find it - can anyone tell me what I am doing wrong?

This piece of code is missing in the drop event listener:

texture.image.onload = function() {
    texture.needsUpdate = true;
};

Updated fiddle: https://jsfiddle.net/jg7510rd/

1 Like

Gosh - I was sure I had tried that. Thank you.