TEXT For developers

Gravity Shift: Low-Poly Physics Platformer

Contributed by loshu2000

Improved by Laravel Company · 2026-09-07

You are an expert game developer specializing in 3D physics simulations and creative JavaScript implementation. Your task is to architect and provide the core technical implementation for a unique puzzle-platformer concept called "Gravity Shift."

Game Concept & Aesthetic:
The game is a 3D puzzle-platformer where the core mechanic involves rotating the entire world's gravity vector.

  • Environment: A minimalist, 3D low-poly labyrinth.
  • Style: The aesthetic must be clean, utilizing pastel gradients and sharp, geometric shapes.

Technical Requirements:
Implement the core physics and rendering system using Three.js for rendering and Cannon.js for physics simulation.

Core Mechanics Implementation:

  1. World Setup: The initial environment should be a defined cube-shaped maze.
  2. Gravity Manipulation: Implement the ability for the player to rotate the world's gravity vector. When the user presses the 'R' key, the global gravity vector must rotate by 90 degrees around the relevant axis, dynamically changing how physics objects behave.
  3. Smooth Camera Control: Implement smooth interpolation for the camera. The camera must follow the player's rigid body, utilizing Lerp (Linear Interpolation) to ensure smooth transitions and avoid jarring shifts during gravity changes.

Specific Code Focus:
Provide the complete, structured JavaScript code that demonstrates the setup, the physics world initialization, the gravity rotation logic, and the smooth camera interpolation mechanism. Ensure the physics loop correctly updates based on the rotated gravity vector.

Desired Output:
Provide a comprehensive, runnable JavaScript structure demonstrating the integration of Three.js, Cannon.js, and the custom gravity rotation mechanic. Focus on clarity, efficiency, and correct physics handling.

Original prompt (before our improvements)

Game Concept: A puzzle-platformer named "Gravity Shift" where players rotate the entire world to navigate a 3D low-poly labyrinth. The environment is minimalist, using pastel gradients and sharp geometric shapes. Technical Prompt: Build a 3D platformer using Three.js and Cannon.js. The world is a cube-shaped maze. When the user presses 'R', rotate the world.gravity vector by 90 degrees. JavaScript // Gravity rotation logic world.gravity.set(0, -9.82, 0); // Default function rotateGravity() { let newG = new CANNON.Vec3(-world.gravity.y, world.gravity.x, 0); world.gravity.copy(newG); } Include smooth camera interpolation using Lerp to follow the player's rigid body during shifts.