<?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: Jeremy Moore</title>
    <description>The latest articles on DEV Community by Jeremy Moore (@moremooredesign).</description>
    <link>https://dev.to/moremooredesign</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%2F157667%2Ffb2f5071-9214-4b55-9c83-417f94fa0f98.jpeg</url>
      <title>DEV Community: Jeremy Moore</title>
      <link>https://dev.to/moremooredesign</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/moremooredesign"/>
    <language>en</language>
    <item>
      <title>Seeking some closure</title>
      <dc:creator>Jeremy Moore</dc:creator>
      <pubDate>Fri, 19 Apr 2019 21:00:39 +0000</pubDate>
      <link>https://dev.to/moremooredesign/seeking-some-closure-392m</link>
      <guid>https://dev.to/moremooredesign/seeking-some-closure-392m</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;As part of my effort to better understand how functions work in Javascript, I had reviewed the concept of closure and how powerful it can be when it comes to organizing code. I won't go over closure here, but you can read more from Mozilla &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures"&gt;here&lt;/a&gt;. The specific issue I dealt with involved accessing the closure variables in an inner function.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can't see bloody A,B,C or D
&lt;/h3&gt;

&lt;p&gt;A situation I had never encountered before involving the Scope debugging panel in Chrome. I was attempting to determine the value assigned to a variable by a function call while inside a nested function. A simplified version of the scenario is below:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function testing() {

    var a = "modern";
    var b = "major";
    var c = "general";

    function innerFunction() {
        console.log(`Not using parent function var`);
    }

    innerFunction();

};
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If you were to run the function &lt;code&gt;testing()&lt;/code&gt;, you would see that there is no sign of the variables &lt;code&gt;a,b or c&lt;/code&gt; if a breakpoint is placed inside the &lt;code&gt;innerFunction()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--S7gyLb1K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/667dr8tvk5r1rqp5wcd8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--S7gyLb1K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/667dr8tvk5r1rqp5wcd8.png" alt="Image of Chrome debugger sidebar"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  I can't see you
&lt;/h3&gt;

&lt;p&gt;What I discovered was that the values of references in the outer function are not visible in the inner function unless they are actually used. Making a one line change to the above example results in this:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function testingClosure() {

    var a = "modern";
    var b = "major";
    var c = "general";

    function innerFunction() {
        console.log(`Using parent function var, value: ${a}`)
    }

    innerFunction();

};
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The outer &lt;code&gt;testingClosure()&lt;/code&gt; function variables are now available inside the &lt;code&gt;innerFunction()&lt;/code&gt; for debugging.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3AXQg7R---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/0l8h58smbjq42gzprjzd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3AXQg7R---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/0l8h58smbjq42gzprjzd.png" alt="Image of Chrome debugger sidebar with closure variables"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I had originally wanted to examine the value of &lt;code&gt;a&lt;/code&gt; inside the inner function without writing any code, but due to the way browser debugging works, there was no way around it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Codepen
&lt;/h3&gt;

&lt;p&gt;You can experiment with closures here:&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/moremooredesign/embed/vMdVzm?height=600&amp;amp;default-tab=js&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Try placing a &lt;code&gt;debugger&lt;/code&gt; statement in the inner function and see the &lt;code&gt;scope&lt;/code&gt; difference.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>functions</category>
      <category>closures</category>
    </item>
    <item>
      <title>You Can't Escape The Mesh</title>
      <dc:creator>Jeremy Moore</dc:creator>
      <pubDate>Thu, 18 Apr 2019 01:14:50 +0000</pubDate>
      <link>https://dev.to/moremooredesign/you-can-t-escape-the-mesh-jlm</link>
      <guid>https://dev.to/moremooredesign/you-can-t-escape-the-mesh-jlm</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;When I first began studying web development several years ago I was attracted to 3D graphics, having come from an architecture background where I did a lot of work in 3DsMax, and later Revit. I ended up doing a group project that combined my love of 3D with motion tracking using the Leap Motion tracker. The result was a 3D hand controlled version of the classic game Pong, built using the ThreeJS library. My interest in 3D has persisted, through playing games like Portal. Eventually I decided it was time to try some more development. Question was: where to begin?&lt;/p&gt;

&lt;p&gt;&lt;a href="http://moremooredesign.com/crazy-leap-pong/"&gt;You can read my article about creating Crazy Leap Pong here&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Rediscovering the joy of Descent
&lt;/h3&gt;

&lt;p&gt;One of the first computer games I played intensely was the 3D shooter game Descent. This was where I was introduced to the concept of portal rendering, only rendering what needs to be rendered in 3D. Descent handles this concept quite nicely since the setting consists of mines with multiple chambers. If you're in one chamber and there's a door, there's no need to render the next chamber until you open the door. I decided that this would be a good exercise for creating a navigable 3D experience. My previous work had been simple simulations of objects in motion.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating the opening scene
&lt;/h3&gt;

&lt;p&gt;I decided to create a simple chamber to chamber environment, where the two chambers would be linked to a tunnel that would only be revealed after a door was opened. I quickly realized that cubes in 3D have no "solidity" unless you specify that they do; otherwise, they are simply objects with six sides that you can't see through. Therefore, I simply created a cube and placed my camera inside of it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Open, Sesame
&lt;/h3&gt;

&lt;p&gt;I handled collision detection by using the ThreeJS Raycaster to determine if the direction of travel would intersect one of the sides of the surrounding cube. In order to escape the chamber, the user would need to navigate to the door and press a key.&lt;/p&gt;

&lt;p&gt;This action would trigger the rendering of the rest of the environment: the tunnel and the other chamber. Until this point the starting chamber was the extent of the world. I used another library to handle the union operation to combine the newly rendered tunnel and destination chamber with the starting chamber into one mesh.&lt;/p&gt;

&lt;h3&gt;
  
  
  Demo
&lt;/h3&gt;

&lt;p&gt;The CodePen is below. Feel free to explore.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/moremooredesign/embed/wpaPra?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>3d</category>
      <category>threejs</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
