Date: 2025-03-30 Focus: Setting up
a basic Three.js
environment for the Metaverse Sandbox. The
goal was to render a 3D land tile scene in the browser that can later be
connected to smart contracts for NFT-based land ownership.
To initialize a clean and expandable 3D space using Three.js, where land parcels could be visualized, clicked, and eventually tied to wallet-owned NFTs.
index.html
main.js
style.css
The script renders a flat 10x10 grid of 3D tiles (cubes) on a plane with a basic camera and lighting setup.
// main.js
import * as THREE from 'three'
// Scene: where all objects live
const scene = new THREE.Scene()
.background = new THREE.Color(0xf0f0f0)
scene
// Camera: field of view, aspect ratio, near/far clipping
const camera = new THREE.PerspectiveCamera(
75,
window.innerWidth / window.innerHeight,
0.1,
1000
).position.set(0, 20, 20)
camera.lookAt(0, 0, 0)
camera
// Renderer: draws everything
const renderer = new THREE.WebGLRenderer({ antialias: true })
.setSize(window.innerWidth, window.innerHeight)
rendererdocument.body.appendChild(renderer.domElement)
// Light
const ambientLight = new THREE.AmbientLight(0xffffff, 0.6)
.add(ambientLight)
scene
const directionalLight = new THREE.DirectionalLight(0xffffff, 0.6)
.position.set(5, 10, 7.5)
directionalLight.add(directionalLight)
scene
// Grid of cubes (land parcels)
const tileSize = 1
const spacing = 1.5
const tilesX = 10
const tilesZ = 10
const tileGeometry = new THREE.BoxGeometry(tileSize, 0.2, tileSize)
const tileMaterial = new THREE.MeshStandardMaterial({ color: 0x3aa6b9 })
for (let x = 0; x < tilesX; x++) {
for (let z = 0; z < tilesZ; z++) {
const tile = new THREE.Mesh(tileGeometry, tileMaterial.clone())
.position.set(
tile- tilesX / 2) * spacing,
(x 0,
- tilesZ / 2) * spacing
(z
).add(tile)
scene
}
}
// Render loop
function animate() {
requestAnimationFrame(animate)
.render(scene, camera)
renderer
}animate()
// Handle window resize
window.addEventListener('resize', () => {
.aspect = window.innerWidth / window.innerHeight
camera.updateProjectionMatrix()
camera.setSize(window.innerWidth, window.innerHeight)
renderer })
scene
is the 3D world container.renderer
handles drawing the scene to a canvas.tileSize
and
spacing
.MeshStandardMaterial
gives them a colored surface with
lighting response.npm install three
).index.html
.index.html
in your browser.ethers.js
or
wagmi
.Summary
Today’s work laid the foundation for a 3D land parcel viewer. Three.js
will be the visual layer for the Metaverse Sandbox, with NFTs tied to
specific tile locations. Next dev session will focus on interactivity
and wallet integration.