Prompt: Isometric 3D Farming Simulator (Three.js)
Core Technical Stack
- Library: Three.js (r128+)
- Loader: GLTFLoader for external assets.
- Camera: OrthographicCamera for a true isometric view.
- Position:
(20, 20, 20)looking at(0, 0, 0). - View frustum:
d = 10.
Scene Setup
- Background: Solid color
#a3d5ff. - Lighting: - AmbientLight (Intensity: 0.7).
- DirectionalLight (Intensity: 0.9) at
(10, 20, 10)with shadow casting enabled. - Environment:
- Ground: A 15x1x15 BoxGeometry colored
#7cfc00(Grass), positioned aty = -0.51. - Pond: A CylinderGeometry (radius 2, height 0.4) colored
#00a8ff. Position:(-4, 0.01, -4). Add a subtle sine-wave animation to theyposition to simulate water movement.
Asset Handling: Farming Plot
- Model URL:
https://cloudxlr.com/resources/models/farmingplot.glb - Transformation Rules:
- Scale:
0.6for all axes. - Rotation: Must be rotated
Math.PI / 2(90 degrees) on the Y-axis to align with the isometric grid. - Positions: Place three plots at the following coordinates:
(3, 0, 4)(3, 0, 0)(3, 0, -4)- Color Logic:
- On initialization, traverse the model and store the original material colors in
node.userData.originalColor. - When watered,
lerpthe material color towards black by0.4to represent wet soil. - On harvest, restore the exact
originalColor.
Interaction & UI Logic
- Raycasting: Use a Raycaster to detect clicks.
- The Bucket System:
- Clicking the Pond makes a bucket (CylinderGeometry) appear.
- Critical Rule: Set
bucket.raycast = function() {};so the bucket does not block the Raycaster from hitting the plots or ground. - The bucket must follow the mouse cursor projected onto the ground plane.
- States:
EMPTY: Default state. Clicking with a bucket transitions toGROWING.GROWING: Procedural plants (stem + leaves) scale from0.1to1.5over 5 seconds.READY: Plant turns bright green. A Golden Outline appears.- Golden Outline Effect:
- Do not use a box helper.
- Traverse the plot model and create duplicates of its meshes.
- Set the duplicate material to
THREE.MeshBasicMaterialwithcolor: 0xffd700andside: THREE.BackSide. - Scale the duplicate slightly larger (
multiplyScalar(1.06)). - Animate
material.opacitywith a sine wave for a pulsing glow. - Harvesting:
- Clicking a
READYplot opens a custom HTML modal. - Closing the modal increments the score, clears the plant, and removes the golden outline.
Performance & UX
- Handle window resizing by updating the OrthographicCamera frustum.
- Instructions overlay at the bottom: "Click Pond to get Water • Click Plot to Plant • Click Grown Crop to Harvest".