Grid + Axes Helpers

Visual helpers to understand world orientation and scale.

What this code does

- GridHelper: creates a 10x10 grid with green center lines and gray subdivisions.
- AxesHelper: displays X (red), Y (green), Z (blue) axes for world orientation.
- These helpers are essential for debugging 3D scenes and understanding scale.
- OrbitControls allows inspection from different angles.

JavaScript (plain)

import * as THREE from 'three'
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'

const scene = new THREE.Scene()
const camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000)
camera.position.set(2, 2, 3)

const renderer = new THREE.WebGLRenderer({ antialias: true })
renderer.setSize(width, height)

document.querySelector('#app').appendChild(renderer.domElement)

const controls = new OrbitControls(camera, renderer.domElement)
controls.target.set(0, 0, 0)
controls.update()

const grid = new THREE.GridHelper(10, 10, 0x9bdc6e, 0x333333)
scene.add(grid)

const axes = new THREE.AxesHelper(1.5)
scene.add(axes)

function animate() {
  requestAnimationFrame(animate)
  controls.update()
  renderer.render(scene, camera)
}
animate()