Crossfade background images between scenes


I am trying to build a project, where each scene has a different background image, I wish the background image to be static, and it shouldn’t move when I scroll.
I have managed to create the static background image by having an “html” style attribute in my head HTML: html { background: url(${resourcesFolderName}/MyBG.jpg) }
It’s working, but now I wish this background image to crossfade to another background image when I switch between scenes. I have tried doing this by running a javascript function on scene load: = "url(${resourcesFolderName}/SecondBG.jpg)";
It’s switching the backgrounds, but it wont provide me the crossfade effect between the backgrounds.
Is there any workaround to make this possible?

Thank You.

(james koh) #2

I dont understand why you want to do it in harder way.
you can just choose jump to scene, and choose crossfade for transition.
then each scene you can put background images that you want.
maybe you have a special reason that I don’t know yet.


I haven’t found any easier way to set a scene background image, only background color.
I used this article to change the background image:

(Andrew) #4

The simplest way to do this, is by having a function on each Scene load that changes the background of the page.

But something along the lines as:

$('body').css('background', 'black');

of a switch function that will do the same and accessible in one place:

switch(bg) {

case "home":	
	$('body').css('background', 'black');

case "about":	
	$('body').css('background', 'yellow');
} (93.7 KB)


I found an easier fix, I just added transition: background 1.5s linear attribute to the html element in the head, and made the background change onload by = "url(${resourcesFolderName}/newBG.jpg) "; and that solved it.