<?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[Code for Thought]]></title><description><![CDATA[Software Craftsman at RoleModel Software.

I love writing Ruby, CSS, building web applications, and design systems.]]></description><link>https://coding.thewaltons.family</link><generator>RSS for Node</generator><lastBuildDate>Thu, 09 Apr 2026 12:04:25 GMT</lastBuildDate><atom:link href="https://coding.thewaltons.family/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Should you style HTML Elements directly?]]></title><description><![CDATA[Over the last year and a half, I have been developing a Design System for RoleModel Software. This has required a high level of collaboration between me (a full-stack developer who primarily enjoys front-end work) and our design team (specifically ou...]]></description><link>https://coding.thewaltons.family/should-you-style-html-elements-directly</link><guid isPermaLink="true">https://coding.thewaltons.family/should-you-style-html-elements-directly</guid><category><![CDATA[HTML]]></category><category><![CDATA[CSS]]></category><category><![CDATA[Sass]]></category><category><![CDATA[Design Systems]]></category><category><![CDATA[optics]]></category><dc:creator><![CDATA[Jeremy Walton]]></dc:creator><pubDate>Thu, 17 Aug 2023 19:39:46 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1690571775863/a157d768-e48e-4ed2-85a9-f31bd5fdb946.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Over the last year and a half, I have been developing a Design System for <a target="_blank" href="https://rolemodelsoftware.com/">RoleModel Software</a>. This has required a high level of collaboration between me (a full-stack developer who primarily enjoys front-end work) and our design team (specifically our Design Director).</p>
<p>We call it <a target="_blank" href="https://docs.optics.rolemodel.design/?path=/docs/overview-introduction--docs">Optics, a RoleModel Design System</a></p>
<p>Early on in our collaboration, a question came up as to how we style our inputs.</p>
<blockquote>
<p>Should we design all of the inputs in our system to have styles applied directly to the HTML Elements? Wouldn't that be easier than requiring <code>.form-control</code> to render the styles?</p>
</blockquote>
<p>This question applies to more than just form controls as well such as styling buttons directly or always using a class like <code>.btn</code>.</p>
<pre><code class="lang-scss"><span class="hljs-selector-class">.form-control</span> {
  <span class="hljs-comment">// Shared styles go here</span>
}
<span class="hljs-comment">// OR</span>
<span class="hljs-selector-tag">input</span><span class="hljs-selector-attr">[type="text"]</span>,
<span class="hljs-selector-tag">input</span><span class="hljs-selector-attr">[type="password"]</span>,
<span class="hljs-selector-tag">input</span><span class="hljs-selector-attr">[type="search"]</span>
<span class="hljs-selector-tag">input</span><span class="hljs-selector-attr">[type="date"]</span>,
<span class="hljs-selector-tag">input</span><span class="hljs-selector-attr">[type="datetime-local"]</span>,
<span class="hljs-selector-tag">input</span><span class="hljs-selector-attr">[type="email"]</span>,
<span class="hljs-selector-tag">input</span><span class="hljs-selector-attr">[type="month"]</span>,
<span class="hljs-selector-tag">input</span><span class="hljs-selector-attr">[type="number"]</span>,
<span class="hljs-selector-tag">input</span><span class="hljs-selector-attr">[type="tel"]</span>,
<span class="hljs-selector-tag">input</span><span class="hljs-selector-attr">[type="time"]</span>,
<span class="hljs-selector-tag">input</span><span class="hljs-selector-attr">[type="url"]</span>,
<span class="hljs-selector-tag">input</span><span class="hljs-selector-attr">[type="week"]</span>
<span class="hljs-selector-tag">textarea</span> {
  <span class="hljs-comment">// Shared styles go here</span>
}
</code></pre>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">'text'</span> <span class="hljs-attr">class</span>=<span class="hljs-string">'form-control'</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">'email'</span> <span class="hljs-attr">class</span>=<span class="hljs-string">'form-control'</span>&gt;</span>
<span class="hljs-comment">&lt;!-- OR --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">'text'</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">'email'</span>&gt;</span>
</code></pre>
<h2 id="heading-so-should-you-no-use-classes">So should you? No, use classes.</h2>
<p>Let me explain why by addressing some potential concerns.</p>
<h3 id="heading-concern-1-requiring-a-class-creates-a-worse-developer-experience">Concern #1: Requiring a class creates a worse Developer Experience</h3>
<p>Needing to remember to use a class every time adds complexity to the Developer Experience and friction to implementation right?</p>
<p>While this can be true of some elements like buttons, inputs, or other semantic HTML elements, requiring a class means the HTML has to be written with more intention and care. It also provides semantic meaning and in some cases intention revealing names to elements or concepts that might not have a dedicated semantic HTML element.</p>
<h3 id="heading-concern-2-requiring-a-class-leads-to-unexpected-default-behavior">Concern #2: Requiring a class leads to unexpected default behavior</h3>
<p>The fundamental purpose of a Design System is to provide styling for a cohesive user experience. Shouldn't elements behave correctly without using classes?</p>
<p>Most design systems provide component libraries to solve this. They ensure you always use the styled and "blessed" default approach by providing a simpler interface. Even they don't override default styles though. If you ever needed to add a new component based on an input element but with a different use case or something along those lines, they still allow for it.</p>
<p>Optics doesn't have a component library (yet), but it does have component blueprints (HTML snippets) with the right semantic elements and classes applied that you can copy and adjust as needed.</p>
<h3 id="heading-concern-3-this-feels-like-shaping-the-code-toward-an-edge-case">Concern #3: This feels like shaping the code toward an edge case</h3>
<p>Opening the door for straying from our design patterns feels like encouraging edge cases. Shouldn't we avoid writing code to allow for this?</p>
<p>Allowing for intentional variation and customization is not an edge case, but rather a feature of a cross-product Design System. It doesn't lock you into one way of thinking or using the system.</p>
<p><strong>Default styling forces you to use an element in one way and doesn't allow for intentional, well-thought-out divergence from that one case. It assumes that the Design System has thought of every need or use case that could come up.</strong></p>
<p>Any time you need to create a new variation, you would need to un-style and then restyle the element which leads to more confusing and complicated CSS.</p>
<p>Based on my experience working across dozens of applications, you simply cannot account for every need or situation.</p>
<p>Every app has unique challenges and uses elements in different ways. Without flexibility, every app built with the same Design System ends up getting locked into a similar look and feel and loses any uniqueness or character. A Design System should provide consistency and standardization, but should still allow for character to show through.</p>
]]></content:encoded></item><item><title><![CDATA[Skybox in Three.js]]></title><description><![CDATA[Note: I'm sure most of this is outdated at this point, but wanted to move the article from my previous blog for archive purposes.  
Three.js is a javascript 3D library that makes WebGL very simple. Today we will see how to set up a scene with a skybo...]]></description><link>https://coding.thewaltons.family/skybox-in-threejs</link><guid isPermaLink="true">https://coding.thewaltons.family/skybox-in-threejs</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[ThreeJS]]></category><dc:creator><![CDATA[Jeremy Walton]]></dc:creator><pubDate>Sat, 20 Sep 2014 01:24:26 GMT</pubDate><content:encoded><![CDATA[<p>Note: I'm sure most of this is outdated at this point, but wanted to move the article from my previous blog for archive purposes.  </p>
<p>Three.js is a javascript 3D library that makes WebGL very simple. Today we will see how to set up a scene with a skybox in Three.js.</p>
<p>The first thing we need is an HTML file.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"http://cdnjs.cloudflare.com/ajax/libs/three.js/r58/three.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
  <span class="hljs-comment">// Everything will happen in here.</span>
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
</code></pre>
<p>As you can see we are loading in Three.js via <a target="_blank" href="http://www.cdnjs.com/.%EF%BF%BCNext">http://www.cdnjs.com/  
</a>Next, we will set up some variables to be used later.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">var</span> scene, camera, renderer;
</code></pre>
<p>The three main things we need are a <strong>scene</strong> to render on, a <strong>camera</strong> to show us the scene, and a <strong>renderer</strong> to draw on the scene. Now we will call two functions to get everything started.</p>
<pre><code class="lang-javascript">init();
animate();

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">init</span>(<span class="hljs-params"></span>) </span>{

}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">animate</span>(<span class="hljs-params"></span>) </span>{

}
</code></pre>
<p>The <strong>init</strong> function is what we use to initialize the scene, camera, and renderer as well as any other objects we want to show. <strong>Animate</strong> handles the runtime loop and rendering.</p>
<p>Let's start to fill in our init function. We will start with the main components.</p>
<pre><code class="lang-javascript"><span class="hljs-comment">////////////</span>
<span class="hljs-comment">// scene  //</span>
<span class="hljs-comment">////////////</span>
scene = <span class="hljs-keyword">new</span> THREE.Scene();

<span class="hljs-comment">////////////</span>
<span class="hljs-comment">// camera //</span>
<span class="hljs-comment">////////////</span>
camera = <span class="hljs-keyword">new</span> THREE.PerspectiveCamera(<span class="hljs-number">75</span>, <span class="hljs-built_in">window</span>.innerWidth / <span class="hljs-built_in">window</span>.innerHeight, <span class="hljs-number">1</span>, <span class="hljs-number">20000</span>);
camera.position.set(<span class="hljs-number">0</span>, <span class="hljs-number">100</span>, <span class="hljs-number">200</span>);
camera.lookAt(scene.position);

<span class="hljs-comment">//////////////</span>
<span class="hljs-comment">// renderer //</span>
<span class="hljs-comment">//////////////</span>
renderer = <span class="hljs-keyword">new</span> THREE.WebGLRenderer();
renderer.setSize ( <span class="hljs-built_in">window</span>.innerWidth, <span class="hljs-built_in">window</span>.innerHeight );
<span class="hljs-built_in">document</span>.body.appendChild( renderer.domElement );
</code></pre>
<p>Creating the scene is probably the easiest part of setting up a Three.js project.</p>
<p>The camera is a bit more complicated. We make a Perspective Camera which is one of a few options Three.js provides. The arguments we pass in are as follows ( field_of_view, aspect_ratio, near_clip, far_clip ). Field_of_view is how wide your vision is, aspect_ratio is the size of the viewing window, near_clip is how close you can get to an object before it stops rendering, and far_clip is how far away an object can be before it stops rendering. Before we finish here, we set the position of the camera and tell it to look at the scene's position which is (0, 0).</p>
<p>For the renderer, we create a webGL renderer, sets the size to the size of your screen and append its dom Element(the HTML canvas) to the page body.</p>
<p>This is what your file should look like inside the script tag at this point.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">var</span> scene, camera, renderer;

init();
animate();

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">init</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-comment">////////////</span>
  <span class="hljs-comment">// scene  //</span>
  <span class="hljs-comment">////////////</span>
  scene = <span class="hljs-keyword">new</span> THREE.Scene();

  <span class="hljs-comment">////////////</span>
  <span class="hljs-comment">// camera //</span>
  <span class="hljs-comment">////////////</span>
  camera = <span class="hljs-keyword">new</span> THREE.PerspectiveCamera(<span class="hljs-number">75</span>, <span class="hljs-built_in">window</span>.innerWidth / <span class="hljs-built_in">window</span>.innerHeight, <span class="hljs-number">1</span>, <span class="hljs-number">20000</span>);
  camera.position.set(<span class="hljs-number">0</span>, <span class="hljs-number">100</span>, <span class="hljs-number">200</span>);
  camera.lookAt(scene.position);

  <span class="hljs-comment">//////////////</span>
  <span class="hljs-comment">// renderer //</span>
  <span class="hljs-comment">//////////////</span>
  renderer = <span class="hljs-keyword">new</span> THREE.WebGLRenderer();
  renderer.setSize ( <span class="hljs-built_in">window</span>.innerWidth, <span class="hljs-built_in">window</span>.innerHeight );
  <span class="hljs-built_in">document</span>.body.appendChild( renderer.domElement );

}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">animate</span>(<span class="hljs-params"></span>) </span>{

}
</code></pre>
<p>Now that we have the main pieces, let’s fill in our animate function.</p>
<pre><code class="lang-javascript">requestAnimationFrame( animate );
render();
</code></pre>
<p>All this does is tell the renderer to render the scene to the camera(canvas view).</p>
<p>We have a scene, a camera, a renderer that is being updated and everything is finally set for us to show something. The first thing we will add is an x, y, z axes. This will help us visualize the 3D space. Inside of our init function, after make the renderer, add this.</p>
<pre><code class="lang-javascript"><span class="hljs-comment">////////////</span>
<span class="hljs-comment">//  axes  //</span>
<span class="hljs-comment">////////////</span>
<span class="hljs-keyword">var</span> axes = <span class="hljs-keyword">new</span> THREE.AxisHelper(<span class="hljs-number">100</span>);
scene.add(axes);
</code></pre>
<p>Using Three.js built in Helper, adding an axes is as easy as telling it what size we want, in this case 100. Once we make the axes, all we need to do is add it to the scene and viola, we are done.</p>
<pre><code class="lang-javascript"><span class="hljs-comment">////////////</span>
<span class="hljs-comment">// floor  //</span>
<span class="hljs-comment">////////////</span>
<span class="hljs-keyword">var</span> floorTexture = <span class="hljs-keyword">new</span> THREE.ImageUtils.loadTexture( <span class="hljs-string">'images/checkerboard.jpg'</span> );
floorTexture.wrapS = floorTexture.wrapT = THREE.RepeatWrapping;
floorTexture.repeat.set( <span class="hljs-number">10</span>, <span class="hljs-number">10</span> );
<span class="hljs-keyword">var</span> floorMaterial = <span class="hljs-keyword">new</span> THREE.MeshBasicMaterial({ <span class="hljs-attr">map</span>: floorTexture, <span class="hljs-attr">side</span>: THREE.DoubleSide });
<span class="hljs-keyword">var</span> floorGeometry = <span class="hljs-keyword">new</span> THREE.PlaneGeometry(<span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>, <span class="hljs-number">10</span>, <span class="hljs-number">10</span>);
<span class="hljs-keyword">var</span> floor = <span class="hljs-keyword">new</span> THREE.Mesh(floorGeometry, floorMaterial);
floor.position.y = <span class="hljs-number">-0.5</span>;
floor.rotation.x = <span class="hljs-built_in">Math</span>.PI / <span class="hljs-number">2</span>;
scene.add(floor);
</code></pre>
<p>What is a floor without a texture? That's why we load in a texture on the first line. Now that we have a texture, we tell it to wrap ten times(<code>repeat.set( 10, 10 )</code>) in both directions(wrapS and wrapT).</p>
<p>All 3D objects in Three.js are meshes. Meshes are composed of geometry(vertices) and a material(how they reflect light/texture). For our floor, we will use a basic material. This allows us to see it even without a light source. Upon creation, we map the texture on its sides and set it to double-sided since it’s just a plane. For the geometry, we use Plane Geometry passing in a few variables (width, depth, x_position, y_position).<br />Finally, we create the mesh, passing in our geometry and material, set its position and add it to the scene.</p>
<p>That white background is somewhat boring, let’s add a skybox to fill in that empty space.</p>
<pre><code class="lang-javascript"><span class="hljs-comment">////////////</span>
<span class="hljs-comment">// skybox //</span>
<span class="hljs-comment">////////////</span>
<span class="hljs-keyword">var</span> materialArray = [];
materialArray.push(<span class="hljs-keyword">new</span> THREE.MeshBasicMaterial( { <span class="hljs-attr">map</span>: THREE.ImageUtils.loadTexture( <span class="hljs-string">'images/dawnmountain-xpos.png'</span> ) }));
materialArray.push(<span class="hljs-keyword">new</span> THREE.MeshBasicMaterial( { <span class="hljs-attr">map</span>: THREE.ImageUtils.loadTexture( <span class="hljs-string">'images/dawnmountain-xneg.png'</span> ) }));
materialArray.push(<span class="hljs-keyword">new</span> THREE.MeshBasicMaterial( { <span class="hljs-attr">map</span>: THREE.ImageUtils.loadTexture( <span class="hljs-string">'images/dawnmountain-ypos.png'</span> ) }));
materialArray.push(<span class="hljs-keyword">new</span> THREE.MeshBasicMaterial( { <span class="hljs-attr">map</span>: THREE.ImageUtils.loadTexture( <span class="hljs-string">'images/dawnmountain-yneg.png'</span> ) }));
materialArray.push(<span class="hljs-keyword">new</span> THREE.MeshBasicMaterial( { <span class="hljs-attr">map</span>: THREE.ImageUtils.loadTexture( <span class="hljs-string">'images/dawnmountain-zpos.png'</span> ) }));
materialArray.push(<span class="hljs-keyword">new</span> THREE.MeshBasicMaterial( { <span class="hljs-attr">map</span>: THREE.ImageUtils.loadTexture( <span class="hljs-string">'images/dawnmountain-zneg.png'</span> ) }));
<span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i &lt; <span class="hljs-number">6</span>; i++)
   materialArray[i].side = THREE.BackSide;
<span class="hljs-keyword">var</span> skyboxMaterial = <span class="hljs-keyword">new</span> THREE.MeshFaceMaterial( materialArray );
<span class="hljs-keyword">var</span> skyboxGeom = <span class="hljs-keyword">new</span> THREE.CubeGeometry( <span class="hljs-number">5000</span>, <span class="hljs-number">5000</span>, <span class="hljs-number">5000</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span> );
<span class="hljs-keyword">var</span> skybox = <span class="hljs-keyword">new</span> THREE.Mesh( skyboxGeom, skyboxMaterial );
scene.add( skybox );
</code></pre>
<p>Just like before, we need to create a material, but this time we make one for each side of our skybox. This allows us to map a different image to each side. By setting the side to BackSide, Three.js will render the images on the inside of the cube instead of the default outside. We have all our materials in an array, but to map them properly, we give the array to another type of material, a face material. Next we create the geometry, this time we use CubeGeometry and pass in (width, height, depth, x_position, y_position, z_position). After creating the mesh we can add it to the scene and now we have a background!</p>
<p>Last, but not least, we will add a simple cube to the scene</p>
<pre><code class="lang-javascript"><span class="hljs-comment">////////////</span>
<span class="hljs-comment">//  cube  //</span>
<span class="hljs-comment">////////////</span>
<span class="hljs-keyword">var</span> material = <span class="hljs-keyword">new</span> THREE.MeshBasicMaterial({ <span class="hljs-attr">map</span>: THREE.ImageUtils.loadTexture(<span class="hljs-string">'images/crate.jpg'</span>) });
<span class="hljs-keyword">var</span> geometry = <span class="hljs-keyword">new</span> THREE.CubeGeometry(<span class="hljs-number">50</span>, <span class="hljs-number">50</span>, <span class="hljs-number">50</span>);
<span class="hljs-keyword">var</span> cube = <span class="hljs-keyword">new</span> THREE.Mesh(geometry, material);
cube.position.set(<span class="hljs-number">0</span>, <span class="hljs-number">25</span>, <span class="hljs-number">0</span>);
scene.add(cube);
</code></pre>
<p>As before, we create a basic material and map an image to it. Next we create the CubeGeometry with a size of 50 on each dimension. Finally we create the mesh, set its position, and add it to the scene.</p>
<p>Here is what everything inside the script tags should look like.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">var</span> scene, camera, renderer;

init();
animate();

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">init</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-comment">////////////</span>
  <span class="hljs-comment">// scene  //</span>
  <span class="hljs-comment">////////////</span>
  scene = <span class="hljs-keyword">new</span> THREE.Scene();

  <span class="hljs-comment">////////////</span>
  <span class="hljs-comment">// camera //</span>
  <span class="hljs-comment">////////////</span>
  camera = <span class="hljs-keyword">new</span> THREE.PerspectiveCamera(<span class="hljs-number">75</span>, <span class="hljs-built_in">window</span>.innerWidth / <span class="hljs-built_in">window</span>.innerHeight, <span class="hljs-number">1</span>, <span class="hljs-number">20000</span>);
  camera.position.set(<span class="hljs-number">0</span>, <span class="hljs-number">100</span>, <span class="hljs-number">200</span>);
  camera.lookAt(scene.position);

  <span class="hljs-comment">//////////////</span>
  <span class="hljs-comment">// renderer //</span>
  <span class="hljs-comment">//////////////</span>
  renderer = <span class="hljs-keyword">new</span> THREE.WebGLRenderer();
  renderer.setSize ( <span class="hljs-built_in">window</span>.innerWidth, <span class="hljs-built_in">window</span>.innerHeight );
  <span class="hljs-built_in">document</span>.body.appendChild( renderer.domElement );

  <span class="hljs-comment">////////////</span>
  <span class="hljs-comment">//  axes  //</span>
  <span class="hljs-comment">////////////</span>
  <span class="hljs-keyword">var</span> axes = <span class="hljs-keyword">new</span> THREE.AxisHelper(<span class="hljs-number">100</span>);
  scene.add(axes);

  <span class="hljs-comment">////////////</span>
  <span class="hljs-comment">// floor  //</span>
  <span class="hljs-comment">////////////</span>
  <span class="hljs-keyword">var</span> floorTexture = <span class="hljs-keyword">new</span> THREE.ImageUtils.loadTexture( <span class="hljs-string">'images/checkerboard.jpg'</span> );
  floorTexture.wrapS = floorTexture.wrapT = THREE.RepeatWrapping;
  floorTexture.repeat.set( <span class="hljs-number">10</span>, <span class="hljs-number">10</span> );
  <span class="hljs-keyword">var</span> floorMaterial = <span class="hljs-keyword">new</span> THREE.MeshBasicMaterial({ <span class="hljs-attr">map</span>: floorTexture, <span class="hljs-attr">side</span>: THREE.DoubleSide });
  <span class="hljs-keyword">var</span> floorGeometry = <span class="hljs-keyword">new</span> THREE.PlaneGeometry(<span class="hljs-number">1000</span>, <span class="hljs-number">1000</span>, <span class="hljs-number">10</span>, <span class="hljs-number">10</span>);
  <span class="hljs-keyword">var</span> floor = <span class="hljs-keyword">new</span> THREE.Mesh(floorGeometry, floorMaterial);
  floor.position.y = <span class="hljs-number">-0.5</span>;
  floor.rotation.x = <span class="hljs-built_in">Math</span>.PI / <span class="hljs-number">2</span>;
  scene.add(floor);

  <span class="hljs-comment">////////////</span>
  <span class="hljs-comment">// skybox //</span>
  <span class="hljs-comment">////////////</span>
  <span class="hljs-keyword">var</span> materialArray = [];
  materialArray.push(<span class="hljs-keyword">new</span> THREE.MeshBasicMaterial( { <span class="hljs-attr">map</span>: THREE.ImageUtils.loadTexture( <span class="hljs-string">'images/dawnmountain-xpos.png'</span> ) }));
  materialArray.push(<span class="hljs-keyword">new</span> THREE.MeshBasicMaterial( { <span class="hljs-attr">map</span>: THREE.ImageUtils.loadTexture( <span class="hljs-string">'images/dawnmountain-xneg.png'</span> ) }));
  materialArray.push(<span class="hljs-keyword">new</span> THREE.MeshBasicMaterial( { <span class="hljs-attr">map</span>: THREE.ImageUtils.loadTexture( <span class="hljs-string">'images/dawnmountain-ypos.png'</span> ) }));
  materialArray.push(<span class="hljs-keyword">new</span> THREE.MeshBasicMaterial( { <span class="hljs-attr">map</span>: THREE.ImageUtils.loadTexture( <span class="hljs-string">'images/dawnmountain-yneg.png'</span> ) }));
  materialArray.push(<span class="hljs-keyword">new</span> THREE.MeshBasicMaterial( { <span class="hljs-attr">map</span>: THREE.ImageUtils.loadTexture( <span class="hljs-string">'images/dawnmountain-zpos.png'</span> ) }));
  materialArray.push(<span class="hljs-keyword">new</span> THREE.MeshBasicMaterial( { <span class="hljs-attr">map</span>: THREE.ImageUtils.loadTexture( <span class="hljs-string">'images/dawnmountain-zneg.png'</span> ) }));
  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i &lt; <span class="hljs-number">6</span>; i++)
     materialArray[i].side = THREE.BackSide;
  <span class="hljs-keyword">var</span> skyboxMaterial = <span class="hljs-keyword">new</span> THREE.MeshFaceMaterial( materialArray );
  <span class="hljs-keyword">var</span> skyboxGeom = <span class="hljs-keyword">new</span> THREE.CubeGeometry( <span class="hljs-number">5000</span>, <span class="hljs-number">5000</span>, <span class="hljs-number">5000</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span> );
  <span class="hljs-keyword">var</span> skybox = <span class="hljs-keyword">new</span> THREE.Mesh( skyboxGeom, skyboxMaterial );
  scene.add( skybox );

  <span class="hljs-comment">////////////</span>
  <span class="hljs-comment">//  cube  //</span>
  <span class="hljs-comment">////////////</span>
  <span class="hljs-keyword">var</span> material = <span class="hljs-keyword">new</span> THREE.MeshBasicMaterial({ <span class="hljs-attr">map</span>: THREE.ImageUtils.loadTexture(<span class="hljs-string">'images/crate.jpg'</span>) });
  <span class="hljs-keyword">var</span> geometry = <span class="hljs-keyword">new</span> THREE.CubeGeometry(<span class="hljs-number">50</span>, <span class="hljs-number">50</span>, <span class="hljs-number">50</span>);
  <span class="hljs-keyword">var</span> cube = <span class="hljs-keyword">new</span> THREE.Mesh(geometry, material);
  cube.position.set(<span class="hljs-number">0</span>, <span class="hljs-number">25</span>, <span class="hljs-number">0</span>);
  scene.add(cube);

}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">animate</span>(<span class="hljs-params"></span>) </span>{
  requestAnimationFrame( animate );
  render();
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">update</span>(<span class="hljs-params"></span>) </span>{

}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">render</span>(<span class="hljs-params"></span>) </span>{
  renderer.render(scene, camera);
}
</code></pre>
<p>There you have it. We have created a simple scene with a floor, axes, a skybox, and a cube as well. The next step is to add some controls to view the rest of the scene. I hope you learned something from this brief tutorial. Feel free to leave a comment and share what you have done with Three.js</p>
<p>Here are the pictures used in this tutorial.</p>
<p><img src="https://jeremypwalton.files.wordpress.com/2014/09/checkerboard.jpg" alt /></p>
<p><img src="https://jeremypwalton.files.wordpress.com/2014/09/crate.jpg?w=300&amp;h=300" alt="crate" /></p>
<p><img src="https://jeremypwalton.files.wordpress.com/2014/09/dawnmountain-xneg.png?w=300&amp;h=300" alt="dawnmountain-xneg" /></p>
<p><img src="https://jeremypwalton.files.wordpress.com/2014/09/dawnmountain-xpos.png?w=300&amp;h=300" alt="dawnmountain-xpos" /></p>
<p><img src="https://jeremypwalton.files.wordpress.com/2014/09/dawnmountain-yneg.png?w=300&amp;h=300" alt="dawnmountain-yneg" /></p>
<p><img src="https://jeremypwalton.files.wordpress.com/2014/09/dawnmountain-ypos.png?w=300&amp;h=300" alt="dawnmountain-ypos" /></p>
<p><img src="https://jeremypwalton.files.wordpress.com/2014/09/dawnmountain-zneg.png?w=300&amp;h=300" alt="dawnmountain-zneg" /></p>
<p><img src="https://jeremypwalton.files.wordpress.com/2014/09/dawnmountain-zpos.png?w=300&amp;h=300" alt="dawnmountain-zpos" /></p>
]]></content:encoded></item></channel></rss>