<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Akashjeet MItra</title>
    <description>The latest articles on DEV Community by Akashjeet MItra (@mittirr).</description>
    <link>https://dev.to/mittirr</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3044255%2F8b3addfd-7d5e-4d8f-a709-abf2c945d1c1.jpeg</url>
      <title>DEV Community: Akashjeet MItra</title>
      <link>https://dev.to/mittirr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mittirr"/>
    <language>en</language>
    <item>
      <title>🚀 Getting Started with Three.js: Building My First 3D Scene</title>
      <dc:creator>Akashjeet MItra</dc:creator>
      <pubDate>Sun, 27 Apr 2025 15:31:06 +0000</pubDate>
      <link>https://dev.to/mittirr/getting-started-with-threejs-building-my-first-3d-scene-29k2</link>
      <guid>https://dev.to/mittirr/getting-started-with-threejs-building-my-first-3d-scene-29k2</guid>
      <description>&lt;p&gt;I have always been fascinated by the magical perspective of 3D websites, and I recently started learning Three.js. It’s such a fun and powerful way to bring 3D into web development!&lt;br&gt;
I’m not an expert (yet 😅), but I thought it would be cool to document my learning journey through blogs.&lt;/p&gt;

&lt;p&gt;If you know basic JavaScript and have been curious about 3D stuff, come along — let’s learn together!&lt;/p&gt;
&lt;h2&gt;
  
  
  📚 What You Need to Know Before Starting
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Basic JavaScript (variables, arrow functions, a little about classes, basic ES6 features).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Basic HTML/CSS.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;That’s it! No prior 3D experience needed. (Trust me, I didn’t have any  either.)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  🛠 Setting Up a Basic Three.js Project
&lt;/h2&gt;

&lt;p&gt;I started super simple — no complicated tools.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Basic HTML Setup&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;meta charset="UTF-8"&amp;gt;
  &amp;lt;title&amp;gt;My First Three.js Project&amp;lt;/title&amp;gt;
  &amp;lt;style&amp;gt;body { margin: 0; }&amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Add Three.js to the Project&lt;/strong&gt;&lt;br&gt;
You can either add a CDN link directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script src="https://unpkg.com/three@latest/build/three.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or, if you’re comfortable using npm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install three
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I used the CDN for my first try — faster setup!&lt;/p&gt;

&lt;h2&gt;
  
  
  🖼️ Building the Basic 3D Scene
&lt;/h2&gt;

&lt;p&gt;From what I understood, in Three.js, you usually need three main things to start:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Scene (like a stage)&lt;/li&gt;
&lt;li&gt;Camera (your viewer’s eye)&lt;/li&gt;
&lt;li&gt;Renderer (to actually draw stuff)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here’s the code I wrote after watching a few tutorials:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// 1. Create the scene
const scene = new THREE.Scene();

// 2. Create the camera
const camera = new THREE.PerspectiveCamera(
  75, 
  window.innerWidth / window.innerHeight, 
  0.1, 
  1000
);
camera.position.z = 5;

// 3. Create the renderer
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🧱 Adding My First 3D Object (A Cube!)
&lt;/h2&gt;

&lt;p&gt;After setting up the scene, I wanted to add something visible. I made a simple green cube:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const geometry = new THREE.BoxGeometry(); // Shape
const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 }); // Looks
const cube = new THREE.Mesh(geometry, material); // Combine shape + look
scene.add(cube); // Add to the scene
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When I ran this, there it was — my little green box floating in space 🧑‍💻.&lt;/p&gt;

&lt;h2&gt;
  
  
  🚀 What’s Next?
&lt;/h2&gt;

&lt;p&gt;Now that I can create a basic scene, here’s what I plan to explore next:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Adding lights (right now the cube looks flat).&lt;/li&gt;
&lt;li&gt;Playing with textures.&lt;/li&gt;
&lt;li&gt;Loading 3D models (.glb or .gltf files).&lt;/li&gt;
&lt;li&gt;Using OrbitControls (to move around the scene with the mouse).
I’ll be writing separate blogs as I figure these things out — stay tuned if you’re learning too!&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
  </channel>
</rss>
