<?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: Kartik Pareek</title>
    <description>The latest articles on DEV Community by Kartik Pareek (@kartik_dev67).</description>
    <link>https://dev.to/kartik_dev67</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%2F3909073%2F08746dc2-dfa4-4366-82df-0d7ff59b57e6.jpeg</url>
      <title>DEV Community: Kartik Pareek</title>
      <link>https://dev.to/kartik_dev67</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kartik_dev67"/>
    <language>en</language>
    <item>
      <title>Three.js</title>
      <dc:creator>Kartik Pareek</dc:creator>
      <pubDate>Sat, 02 May 2026 13:13:57 +0000</pubDate>
      <link>https://dev.to/kartik_dev67/threejs-deb</link>
      <guid>https://dev.to/kartik_dev67/threejs-deb</guid>
      <description>&lt;h1&gt;
  
  
  Three.js &amp;amp; WebGL — Complete Notes
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;📁 &lt;strong&gt;For all code examples and projects, visit the GitHub Repository:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;&lt;a href="https://github.com/kartik-hub-enjay/Advance-Frontend.git" rel="noopener noreferrer"&gt;Advance-Frontend by kartik-hub-enjay&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🌐 What is WebGL?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;WebGL (Web Graphics Library)&lt;/strong&gt; is a JavaScript API that allows you to render 3D and 2D graphics directly in a web browser without needing any plugins.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;WebGL lets you use your &lt;strong&gt;GPU (graphics card)&lt;/strong&gt; to draw graphics on a webpage using the &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt; element.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔷 What is Three.js?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Three.js&lt;/strong&gt; is a JavaScript library that makes it easy to create 3D graphics in the browser using WebGL.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Three.js = an easy layer on top of WebGL&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Instead of writing complex WebGL code, you use simple JavaScript to create 3D scenes.&lt;/p&gt;

&lt;p&gt;When working with Three.js, you always deal with these &lt;strong&gt;3 things&lt;/strong&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Scene&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The world — everything exists here&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Camera&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;What the user sees&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Renderer&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Displays the scene on screen&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Canvas
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;Canvas&lt;/strong&gt; is an HTML element used to draw graphics (2D or 3D) directly on a web page using JavaScript.&lt;/p&gt;




&lt;h2&gt;
  
  
  Scene
&lt;/h2&gt;

&lt;p&gt;In 3D graphics (especially in Three.js), a &lt;strong&gt;Scene&lt;/strong&gt; is the main container that holds everything you want to display.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Scene = the virtual world where all objects exist&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Think of it like a &lt;strong&gt;movie set&lt;/strong&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Movie Analogy&lt;/th&gt;
&lt;th&gt;Three.js Equivalent&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Actors&lt;/td&gt;
&lt;td&gt;Objects (cube, sphere, models)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lights&lt;/td&gt;
&lt;td&gt;Lighting&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Camera&lt;/td&gt;
&lt;td&gt;Viewpoint&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stage&lt;/td&gt;
&lt;td&gt;The Scene itself&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  What Does a Scene Contain?
&lt;/h3&gt;

&lt;p&gt;A scene can include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;3D objects (meshes, models)&lt;/li&gt;
&lt;li&gt;Lights (for brightness and shadows)&lt;/li&gt;
&lt;li&gt;Cameras (to view the scene)&lt;/li&gt;
&lt;li&gt;Animations&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The Core Trio
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Scene&lt;/strong&gt; → What exists  |  &lt;strong&gt;Camera&lt;/strong&gt; → What you see  |  &lt;strong&gt;Renderer&lt;/strong&gt; → Displays it&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The renderer shows the scene through the camera.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Camera
&lt;/h2&gt;

&lt;p&gt;In 3D graphics (like in Three.js), a &lt;strong&gt;Camera&lt;/strong&gt; defines what part of the scene is visible on the screen.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Camera = the viewer's eyes in a 3D world&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Think of shooting a movie:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Scene&lt;/strong&gt; → entire set&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Camera&lt;/strong&gt; → what angle you see&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Screen&lt;/strong&gt; → final output&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Change camera → you see a different view&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Types of Cameras
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1.  Perspective Camera &lt;em&gt;(Most Used)&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Works like human eyes&lt;/li&gt;
&lt;li&gt;Objects far away look smaller&lt;/li&gt;
&lt;li&gt;Used in games, websites, real-world views&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  2. 📐 Orthographic Camera
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;No perspective effect&lt;/li&gt;
&lt;li&gt;Objects stay same size&lt;/li&gt;
&lt;li&gt;Used in 2D games, UI, CAD apps&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Camera Properties
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Property&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Position&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Where the camera is&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Rotation&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Where it is looking&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Field of View (FOV)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;How wide the view is&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Rotation
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Rotation&lt;/strong&gt; = turning an object around an axis&lt;/p&gt;

&lt;p&gt;Objects rotate around &lt;strong&gt;3 axes&lt;/strong&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Axis&lt;/th&gt;
&lt;th&gt;Direction&lt;/th&gt;
&lt;th&gt;Analogy&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;X-axis&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Up / Down tilt&lt;/td&gt;
&lt;td&gt;😮 Nodding head&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Y-axis&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Left / Right spin&lt;/td&gt;
&lt;td&gt;🙅 Shaking head&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Z-axis&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Clockwise / Anticlockwise&lt;/td&gt;
&lt;td&gt;🎡 Rotating a wheel&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Scaling
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Scaling&lt;/strong&gt; = changing the size of an object&lt;/p&gt;

&lt;p&gt;Scaling works on axes:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Axis&lt;/th&gt;
&lt;th&gt;Controls&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;X&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Width&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Y&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Height&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Z&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Depth&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Mesh
&lt;/h2&gt;

&lt;p&gt;In 3D graphics (like in Three.js), a &lt;strong&gt;Mesh&lt;/strong&gt; is the actual visible 3D object you see on the screen.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Mesh = Geometry + Material&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A mesh is made of &lt;strong&gt;2 parts&lt;/strong&gt;:&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Geometry
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Defines the &lt;strong&gt;shape&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Example: cube, sphere, plane&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  2. Material
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Defines the &lt;strong&gt;appearance&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Color, texture, light effect&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Renderer
&lt;/h2&gt;

&lt;p&gt;In the world of Three.js, the &lt;strong&gt;Renderer&lt;/strong&gt; is essentially the engine's &lt;em&gt;"artist."&lt;/em&gt; It takes all the mathematical data you've created — your 3D objects, the lights, and the camera's perspective — and does the hard work of drawing those pixels onto your 2D screen.&lt;/p&gt;

&lt;p&gt;Think of it as the &lt;strong&gt;final step in the pipeline&lt;/strong&gt;: you provide the scene (the stage) and the camera (the eyes), and the renderer produces the image.&lt;/p&gt;

&lt;p&gt;Most Three.js projects use the &lt;strong&gt;&lt;code&gt;WebGLRenderer&lt;/code&gt;&lt;/strong&gt;. This specifically utilizes the browser's WebGL API to harness the power of the user's GPU (Graphics Card). This is why 3D on the web can run at high frame rates (like &lt;strong&gt;60 FPS&lt;/strong&gt;) even with complex geometry.&lt;/p&gt;




&lt;h2&gt;
  
  
  requestAnimationFrame
&lt;/h2&gt;

&lt;p&gt;In Three.js, &lt;strong&gt;&lt;code&gt;requestAnimationFrame&lt;/code&gt; (RAF)&lt;/strong&gt; is the heartbeat of your application. While it is technically a native Web API provided by the browser, it is essential for Three.js because it creates the &lt;strong&gt;Render Loop&lt;/strong&gt; that makes motion possible.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Without it → your 3D scene would be a &lt;strong&gt;static snapshot&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;With it → you can move objects, update physics, and see changes in &lt;strong&gt;real-time&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why use it instead of &lt;code&gt;setInterval&lt;/code&gt;?
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;requestAnimationFrame&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Sync with Refresh Rate&lt;/td&gt;
&lt;td&gt;Matches monitor frame rate (60Hz or 144Hz) — buttery-smooth motion&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Battery &amp;amp; Performance&lt;/td&gt;
&lt;td&gt;Pauses automatically when tab is hidden&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Frame Efficiency&lt;/td&gt;
&lt;td&gt;Executes at the right moment before repaint, reducing jank&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Handling Different Frame Rates
&lt;/h3&gt;

&lt;p&gt;One common &lt;em&gt;"gotcha"&lt;/em&gt; with &lt;code&gt;requestAnimationFrame&lt;/code&gt; is that it runs as fast as the monitor allows. If a user has a 144Hz monitor, your cube will spin much faster than for a user on a 60Hz monitor.&lt;/p&gt;

&lt;p&gt;To fix this, developers use a &lt;strong&gt;Clock&lt;/strong&gt; to ensure animations are &lt;em&gt;"frame-rate independent."&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;clock&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;THREE&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Clock&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;requestAnimationFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// Get the time elapsed since the last frame&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;delta&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;clock&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getDelta&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="c1"&gt;// Move 1 unit per second, regardless of FPS&lt;/span&gt;
  &lt;span class="nx"&gt;mesh&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;position&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;delta&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="nx"&gt;renderer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scene&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;camera&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Orbit Controls
&lt;/h2&gt;

&lt;p&gt;In Three.js, &lt;strong&gt;&lt;code&gt;OrbitControls&lt;/code&gt;&lt;/strong&gt; is a utility that lets the user interactively move the camera around a scene using the mouse or touch.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;OrbitControls = allows you to rotate, zoom, and pan the camera around an object&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;With OrbitControls, users can:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;th&gt;How&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Rotate&lt;/td&gt;
&lt;td&gt;Drag mouse to spin around object&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Zoom&lt;/td&gt;
&lt;td&gt;Scroll to zoom in/out&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pan&lt;/td&gt;
&lt;td&gt;Move left/right/up/down&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Important Note:&lt;/strong&gt; OrbitControls does &lt;strong&gt;NOT&lt;/strong&gt; move objects — it moves the &lt;strong&gt;camera&lt;/strong&gt; around the scene.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Geometry
&lt;/h2&gt;

&lt;p&gt;In 3D graphics (like in Three.js), &lt;strong&gt;Geometry&lt;/strong&gt; defines the shape or structure of an object.&lt;/p&gt;

&lt;p&gt;Geometry is made up of:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Vertices&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Points in space&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Edges&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Lines connecting points&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Faces&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Surfaces (triangles)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Together, they form a 3D shape.&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Geometry only defines &lt;strong&gt;shape&lt;/strong&gt; — it is not visible until combined with a &lt;strong&gt;material&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Materials
&lt;/h2&gt;

&lt;p&gt;In 3D graphics (like in Three.js), &lt;strong&gt;Materials&lt;/strong&gt; define how an object looks on the surface.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Material = the appearance (color, texture, light behavior) of an object&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Types of Materials
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Basic Material&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;No lighting effect — always looks the same&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Standard Material&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Realistic lighting — supports shadows&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Phong Material&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Shiny surface — reflects light&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  What Materials Control
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Color&lt;/li&gt;
&lt;li&gt;Texture (images)&lt;/li&gt;
&lt;li&gt;Shininess&lt;/li&gt;
&lt;li&gt;Light reflection&lt;/li&gt;
&lt;li&gt;Transparency&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Textures
&lt;/h2&gt;

&lt;p&gt;In 3D graphics (like in Three.js), &lt;strong&gt;Textures&lt;/strong&gt; are images applied to the surface of an object to make it look more realistic or detailed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Types of Textures
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Color Map&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Basic image&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Normal Map&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Fake surface details&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Roughness Map&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Smooth/rough surface&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Metalness Map&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Metallic look&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  lil-GUI
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;lil-gui&lt;/code&gt;&lt;/strong&gt; is a small JavaScript library used to create a &lt;strong&gt;control panel&lt;/strong&gt; (UI sliders, buttons, toggles) to interact with your code in real time.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;lil-gui = a UI tool to control variables live (while your app is running)&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When working with 3D (like in Three.js), you often want to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Change colors&lt;/li&gt;
&lt;li&gt;Adjust rotation&lt;/li&gt;
&lt;li&gt;Modify light intensity&lt;/li&gt;
&lt;li&gt;Tune animations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead of editing code again and again, &lt;strong&gt;lil-gui lets you control everything with sliders&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Lights
&lt;/h2&gt;

&lt;p&gt;In Three.js, &lt;strong&gt;Lights&lt;/strong&gt; are what transform a flat, 2D-looking shape into a 3D object with depth, shadows, and contours. Without light, your scene will either be pitch black or — if you are using a &lt;code&gt;MeshBasicMaterial&lt;/code&gt; — flat and devoid of shading.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;To use lights, you need two things: a &lt;strong&gt;Light source&lt;/strong&gt; and a &lt;strong&gt;Material that reacts to light&lt;/strong&gt; (like &lt;code&gt;MeshStandardMaterial&lt;/code&gt; or &lt;code&gt;MeshPhongMaterial&lt;/code&gt;).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Common Light Types
&lt;/h3&gt;

&lt;p&gt;There are several types of lights in Three.js, each serving a specific purpose in a 3D environment.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;See full light type reference: &lt;a href="https://docs.google.com/document/d/13WF_JggZ5yT2HN7rHNu9Iot5zy7uu54QEyguAbryVzQ/edit?usp=sharing" rel="noopener noreferrer"&gt;Three.js Lighting Docs&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Lighting Theory: The "Three-Point" Setup
&lt;/h3&gt;

&lt;p&gt;For professional-looking scenes, developers often use a &lt;strong&gt;"Three-Point Lighting"&lt;/strong&gt; setup:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Light&lt;/th&gt;
&lt;th&gt;Role&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Key Light&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Main light source&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Fill Light&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Softens shadows&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Back Light&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Creates a rim effect, separates object from background&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Working with Shadows
&lt;/h3&gt;

&lt;p&gt;Shadows are computationally &lt;em&gt;"expensive,"&lt;/em&gt; so they are &lt;strong&gt;disabled by default&lt;/strong&gt;. To see shadows, follow this three-step checklist:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Step 1: Enable the Renderer&lt;/span&gt;
&lt;span class="nx"&gt;renderer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;shadowMap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;enabled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Step 2: Enable the Light&lt;/span&gt;
&lt;span class="nx"&gt;light&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;castShadow&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Step 3: Enable the Objects&lt;/span&gt;
&lt;span class="nx"&gt;mesh&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;castShadow&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;       &lt;span class="c1"&gt;// Object casts shadow&lt;/span&gt;
&lt;span class="nx"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;receiveShadow&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// Floor receives shadow&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Helpers: "Seeing" the Light
&lt;/h3&gt;

&lt;p&gt;Since lights are &lt;strong&gt;invisible&lt;/strong&gt;, it can be frustrating to guess where they are pointing. Three.js provides &lt;strong&gt;Helpers&lt;/strong&gt; to visualize them.&lt;/p&gt;




&lt;h2&gt;
  
  
  📁 Code Reference
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;All code examples, projects, and implementations are available on GitHub:&lt;/p&gt;

&lt;p&gt;🔗 &lt;strong&gt;&lt;a href="https://github.com/kartik-hub-enjay/Advance-Frontend.git" rel="noopener noreferrer"&gt;https://github.com/kartik-hub-enjay/Advance-Frontend.git&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>gsap</category>
      <category>animation</category>
    </item>
  </channel>
</rss>
