<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Understanding Three.js Normal Mesh]]></title><description><![CDATA[Understanding Three.js Normal Mesh]]></description><link>https://normalmeshinthreejs.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sun, 18 Oct 2026 15:33:45 GMT</lastBuildDate><atom:link href="https://normalmeshinthreejs.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Understanding MeshNormalMaterial  in THREE.JS]]></title><description><![CDATA[💡what you will learn

What is MeshNormalMaterial

About Normal Vector

Why Normals are Important

How to Create a Normal

THREE Normal Helpers

When to Use


💡Normal Vector
In 3D normal is a vector that is perpendicular to the surface or a face of ...]]></description><link>https://normalmeshinthreejs.hashnode.dev/understanding-meshnormalmaterial-in-threejs</link><guid isPermaLink="true">https://normalmeshinthreejs.hashnode.dev/understanding-meshnormalmaterial-in-threejs</guid><category><![CDATA[ThreeJS]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[three.js]]></category><category><![CDATA[Frontend Development]]></category><dc:creator><![CDATA[The3Guy]]></dc:creator><pubDate>Sat, 09 Nov 2024 19:11:18 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1731179353717/61da0f65-5a32-4118-b790-34bc09f92493.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<hr />
<p>💡what you will learn</p>
<ul>
<li><p>What is MeshNormalMaterial</p>
</li>
<li><p>About Normal Vector</p>
</li>
<li><p>Why Normals are Important</p>
</li>
<li><p>How to Create a Normal</p>
</li>
<li><p>THREE Normal Helpers</p>
</li>
<li><p>When to Use</p>
</li>
</ul>
<h3 id="heading-normal-vector">💡Normal Vector</h3>
<p>In 3D <code>normal</code> is a <a target="_blank" href="https://www.superprof.co.uk/resources/academic/maths/geometry/line/normal-vector.html">vector</a> that is perpendicular to the surface or a face of 3D model. These <code>normal</code> tell and define how light interacts with the surface of 3d models.</p>
<p>They help to determine how the surface should appear on the basis of viewer perspective and the direction of light sources.</p>
<p>A <code>normal</code> vector is perpendicular to the face of a vertex. The normal vector is used in many different parts of Three.js. It is used to determine light reflections, helps with mapping textures to 3D models, and provides information on how to light, shade, and color pixels on the surface</p>
<h3 id="heading-why-normals-are-important">💡Why Normals Are Important</h3>
<ul>
<li><p><strong>Lighting Calculations</strong>: These are used to determine how bright a surface should appear based on the angle between the normal and the light source.</p>
</li>
<li><p><strong>Surface Appearance</strong>: They can help create <code>realistic rendering</code> effects such as shading, highlights and shadows.</p>
</li>
</ul>
<hr />
<h3 id="heading-creating-a-meshnormalmaterialhttpsthreejsorgdocsindexhtmlapienmaterialsmeshnormalmaterial">💡Creating a <a target="_blank" href="https://threejs.org/docs/index.html#api/en/materials/MeshNormalMaterial">MeshNormalMaterial</a></h3>
<p>you can check the live preview here <a target="_blank" href="https://threejs.org/docs/index.html#api/en/materials/MeshNormalMaterial">MeshNormalMaterial</a></p>
<ul>
<li><p>1st create a <code>BoxGeometry()</code> and <code>MeshNormalMaterial()</code></p>
</li>
<li><p>then we make <code>Mesh()</code> and add it to our <code>scene</code></p>
</li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-comment">// Create a torus geometry and apply MeshNormalMaterial</span>
<span class="hljs-keyword">const</span> geometry = <span class="hljs-keyword">new</span> THREE.TorusGeometry(<span class="hljs-number">1</span>, <span class="hljs-number">0.4</span>, <span class="hljs-number">16</span>, <span class="hljs-number">100</span>);
<span class="hljs-keyword">const</span> material = <span class="hljs-keyword">new</span> THREE.MeshNormalMaterial({ <span class="hljs-attr">flatShading</span>: <span class="hljs-literal">true</span> });
<span class="hljs-keyword">const</span> torus = <span class="hljs-keyword">new</span> THREE.Mesh(geometry, material);
scene.add(torus);
</code></pre>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">make sure to set camera some distance from you → <code>camera.position.z = 5;</code></div>
</div>

<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1731177829563/339d88ec-8488-4030-8ad1-eb921f0b6ed0.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-to-see-the-normals-we-add-an-helper">💡To See The Normals We add an Helper</h3>
<p>This can help to visualize the normals and shadding</p>
<ul>
<li><p>1st import the <code>VertexNormalsHelper</code></p>
</li>
<li><p>then use <code>VertexNormalsHelper()</code> and provide the mesh and size along with normal vectors color</p>
</li>
</ul>
<pre><code class="lang-javascript">Import { VertexNormalsHelper } <span class="hljs-keyword">from</span> <span class="hljs-string">'three/examples/jsm/
 helpers/VertexNormalsHelper'</span>

<span class="hljs-comment">// your mesh </span>

<span class="hljs-keyword">const</span> helper = <span class="hljs-keyword">new</span> VertexNormalsHelper(mesh, <span class="hljs-number">0.1</span>, <span class="hljs-number">0xff0000</span>)
helper.name = <span class="hljs-string">'VertexNormalHelper'</span>
scene.add(helper)
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1731178144153/a5ab952d-2699-45ec-bdc9-eed1863ff5c3.png" alt class="image--center mx-auto" /></p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text"><strong>RGB Components Linked to XYZ Coordinates</strong> Tells about axis</div>
</div>

<ol>
<li><p><strong>Red:</strong> X direction</p>
<ul>
<li><p><strong>Positive X direction</strong> = Bright Red</p>
</li>
<li><p><strong>Negative X direction</strong> = Darker, more muted Red</p>
</li>
</ul>
</li>
<li><p><strong>Green:</strong> Y direction</p>
<ul>
<li><p><strong>Positive Y direction</strong> = Bright Green</p>
</li>
<li><p><strong>Negative Y direction</strong> = Darker Green</p>
</li>
</ul>
</li>
<li><p><strong>Blue:</strong> Z direction</p>
<ul>
<li><p><strong>Positive Z direction</strong> = Bright Blue</p>
</li>
<li><p><strong>Negative Z direction</strong> = Darker Blue</p>
</li>
</ul>
</li>
</ol>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">The dynamic color shifts during rotation help you visualize how different parts of the object are oriented in 3D space.</div>
</div>

<hr />
<h3 id="heading-when-to-use-meshnormalmaterial"><strong>💡When to Use</strong> <code>MeshNormalMaterial</code></h3>
<ul>
<li><p>In Debugging the Geometry</p>
</li>
<li><p>Artistic Effects when there is such kind of lighting is required</p>
</li>
<li><p>Lightweight Material</p>
</li>
<li><p>When you want Flat Shading in your project</p>
</li>
</ul>
<p>✌️ Thankyou for reading please share this article with your friends and check The3Guy for 3D world</p>
]]></content:encoded></item></channel></rss>