Skip to content

[BUG]: The GitHub Globe component is buggy. #253

@NirvanaCh7

Description

@NirvanaCh7

Environment

System:
OS: macOS 15.5
CPU: (10) arm64 Apple M1 Max
Memory: 97.30 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 25.0.0 - /Users//.local/share/mise/installs/node/25.0.0/bin/node
npm: 11.6.2 - /Users//.local/share/mise/installs/node/25.0.0/bin/npm
pnpm: 10.14.0 - /Users//.local/share/mise/installs/pnpm/10.19.0/pnpm
Browsers:
Chrome: 123.0.6312.124
Safari: 18.5
npmPackages:
@vueuse/core: ^13.9.0 => 13.9.0
motion-v: ^1.7.3 => 1.7.3
nuxt: ^4.2.1 => 4.2.1
vue: ^3.5.22 => 3.5.24

Describe the bug

The initialPosition , rotateSpeed and autoRotate parameters have no effect.

Just searching the code shows that:

function animate() {
  globe.rotation.y += 0.01; // Rotate globe
  renderer.render(scene, camera);

  requestAnimationFrame(animate);
}
controls.rotateSpeed = defaultGlobeConfig.autoRotateSpeed || 0.8;

rotate speed <= auto rotate speed ,
initialPosition is not applied to the globe rotation or camera position during auto-rotate.

Here is my solution:

function setupScene() {
......
  if (defaultGlobeConfig.initialPosition) {
    const { lat, lng } = defaultGlobeConfig.initialPosition;
    const pos = latLngToCartesian(lat, lng, 400);
    camera.position.set(pos.x, pos.y, pos.z);
    camera.lookAt(0, 0, 0);
  } 
......
  controls.rotateSpeed = defaultGlobeConfig.autoRotateSpeed || 0.8;
  controls.zoomSpeed = 1;

  controls.autoRotate = false;
  controls.autoRotateSpeed = defaultGlobeConfig.autoRotateSpeed ?? 2.0;
......
}

function animate() {

  if (globe && defaultGlobeConfig.autoRotate) {
    globe.rotation.y += (defaultGlobeConfig.autoRotateSpeed ?? 2.0) * 0.001;
  }
  renderer.render(scene, camera);

  requestAnimationFrame(animate);
}

function latLngToCartesian(lat: number, lng: number, radius = 400) {
  const phi = lat * Math.PI / 180;
  const theta = lng * Math.PI / 180;

  const x = radius * Math.cos(phi) * Math.sin(theta);
  const y = radius * Math.sin(phi);
  const z = radius * Math.cos(phi) * Math.cos(theta);

  return { x, y, z };
}

and delete globe.rotateY & rotateZ

It seems like the porting was done a bit hastily. I'm willing to improve it when I have the time.

Reproduction

No response

Additional context

No response

Screenshots

No response

Logs

Additional information

  • Would you be willing to fix this bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions