Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make only the earth rotate without the background rotating? #192

Open
Diuyilu opened this issue Mar 8, 2024 · 6 comments
Open

Comments

@Diuyilu
Copy link

Diuyilu commented Mar 8, 2024

Situation

I use these code make my earth rotate:

const world = Globe()
world.controls().autoRotate = true;
world.controls().autoRotateSpeed = 1;

But I don't want my background rotate.

How should I implement it?

@vasturiano
Copy link
Owner

@Diuyilu if you want your background to be always static without moving, I'd suggest to just have a static image in a <div> underneath and overlay the globe element on top of that (with a transparent background on the globe itself).

@Diuyilu
Copy link
Author

Diuyilu commented Mar 8, 2024

Thank you, I will try this implementation method!

@Diuyilu Diuyilu closed this as completed Mar 8, 2024
@Diuyilu Diuyilu reopened this Mar 8, 2024
@Diuyilu
Copy link
Author

Diuyilu commented Mar 11, 2024

@vasturiano Do you have any specific code implementation? I tried the method you provided but it didn't work.

@Diuyilu
Copy link
Author

Diuyilu commented Mar 11, 2024

@vasturiano Thank you, I just achieved this effect!My implementation method is as follows:

  1. You need to first set a transparent background for the Globe(),I use backgroundColor('#FF000000')
  2. You need to use z-index to set the stacking position of the earth and background
<div class="parent">
    <div id="globeViz" class="global"></div>
     <div id="background" class="background">
         <img class="backimg" src="./image/background.jpg">
     </div>
</div>
<script>
const world = Globe()
.backgroundColor('#FF000000')
world.controls().autoRotate = true;
world.controls().autoRotateSpeed = 1;
</script>
<style>
    .parent {
        position: relative;
    }

    .global {
        position: absolute;
        z-index: 2;
    }

    .background {
        position: absolute;
        z-index: 1;
    }

    .backimg {
        width: 100vw;
        height: 100vh;
    }
</style>

@clddup
Copy link

clddup commented Sep 13, 2024

I also have the same need, but I don't want to achieve it by setting the div background.

@clddup
Copy link

clddup commented Sep 13, 2024

Are there any other implementation schemes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants