<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Leanne Werner on Medium]]></title>
        <description><![CDATA[Stories by Leanne Werner on Medium]]></description>
        <link>https://medium.com/@leannewerner?source=rss-d27e6a24be1e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*AqeSjsLQaqu2DwIhKOF7XA.jpeg</url>
            <title>Stories by Leanne Werner on Medium</title>
            <link>https://medium.com/@leannewerner?source=rss-d27e6a24be1e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 06:07:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@leannewerner/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Creating Cell Fractured Animations Using Blender and React Three Fiber]]></title>
            <link>https://medium.com/@leannewerner/creating-cell-fractured-animations-using-blender-and-react-three-fiber-dbd0299d4767?source=rss-d27e6a24be1e------2</link>
            <guid isPermaLink="false">https://medium.com/p/dbd0299d4767</guid>
            <category><![CDATA[threejs]]></category>
            <category><![CDATA[react-three-fiber]]></category>
            <category><![CDATA[blender]]></category>
            <dc:creator><![CDATA[Leanne Werner]]></dc:creator>
            <pubDate>Fri, 10 Dec 2021 06:32:07 GMT</pubDate>
            <atom:updated>2021-12-10T06:32:07.304Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently I came across a codesandbox from Paul Henschel called <a href="https://codesandbox.io/s/exploding-crystal-9eeo2?file=/src/App.js">Exploding crystal</a>. I thought it was an amazing use case for demonstrating the power and creativity you can have when pairing Blender animations with Three.js. In this article, we’ll cover the basics of replicating this cell fractured effect in Blender and importing that animation into Three.js via React Three Fiber.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ehR35jt1AKwAgEUzknSGgA.png" /><figcaption>Cell Fracture</figcaption></figure><p><em>This tutorial is made using Blender version 3.0 and Three.js version 0.135. A basic understanding of both Blender and Three.js is required.</em></p><p><strong>Step 1:</strong> <em>Creating a boilerplate r3f project</em>. I created a <a href="https://codesandbox.io/s/react-three-fiber-s6pel">template in codesandbox</a> called React Three Fiber with all the dependencies and basic code to get this project started. You can use this template or create your own, but please be mindful of the dependency versions if you do create you’re own boilerplate.</p><p><strong>Step 2:</strong> <em>Creating the Cell Fractured Effect in Blender.</em> There is an amazing step-by-step <a href="https://www.youtube.com/watch?v=ZG_ZMnKzVTQ">YouTube video by BlenderMania</a> on creating the cell fracture effect. This video is great however, you will need to make four additional changes to your animation to load your file via r3f and achieve a similar effect to Henschel&#39;s. These changes are:</p><ol><li><em>Creating an inside material.</em> Pause the video a <strong>5:53</strong> (before you apply the cell fracture quick effect). With your geometry selected, go to the materials panel and add a second material named ‘inside’. Assign this inside material whatever your desired properties are (color, texture, etc.).</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*WQ8lhUiX6Iuy8FwVHnq9uA.png" /></figure><p>2. <em>Applying the inside material to your object</em>. Pause the video again at <strong>6:35 </strong>(before you select ‘OK’ on the effects option panel). Under the Mesh Data section, change the material index to 1. This will tell Blender to use your recently created material (named ‘inside’) for the interior faces of the cell fractures.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eLTkvMB_sZRcvasLQn3Mmw.png" /></figure><p>3. <em>Baking to keyframes.</em> By <strong>8:50 </strong>we have everything we need for the animation we are replicating, therefore we can stop the video here if desired. With all the cells and the plane selected go to Object and select Rigid Body &gt; Bake to Keyframes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zVfAocE6jPIfwh-MXHC4IA.png" /></figure><p>4. <em>Export to .glb and compress file. </em>Once your ridge body transformations are baked you can export your file by going to File &gt; Export &gt; glTF 2.0 and exporting the file in the glTF Binary format. If your file is rather large you can compress it before you export it by going to Geometry &gt; Compression. Also, if you’d like to export your lighting with your file you can go to Include &gt; Punctula Lights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/1*v5qWxwpTDE-HBc2da6K2qQ.png" /></figure><p><strong>Step 3:</strong> <em>Using </em><a href="https://github.com/pmndrs/gltfjsx"><em>gltfjsx</em></a><em> to create a JSX component.</em> There is an incredibly nifty command line tool called gltfjsx. This package will create an r3f JSX component from your GLTF file. You could run this script through a node sandbox or you can open your editor, drop in your exported.glb file, and run the following command:</p><pre>npx gltfjsx &lt;your-exported-file&gt;.glb</pre><p>This will create a component that you can then copy-paste into your sandbox. You can include the --types flag if you’d like to make this component type-safe.</p><p><strong>Step 4:</strong> <em>Import your</em> <em>JSX component. </em>Place your model into your public folder. Then create a new file in your src directory and paste the component created by gltfjsx. Your file structure might look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*Ui9w7U1395DeI9N59_WX5g.png" /></figure><p>If you do nest your .glb file in a folder as I did you will need to edit your file paths in your component (once in the useGLTF hook and again on the last line of your component in the useGLTF.preload() method).</p><pre>const { nodes, materials, animations } = useGLTF(&quot;/models/&lt;your-model-here&gt;.glb&quot;)</pre><pre>-- and --</pre><pre>useGLTF.preload(&quot;/models/&lt;your-model-here&gt;.glb&quot;);</pre><p><strong>Step 5: </strong><em>Rendering your model.</em> Finally, it&#39;s time to see your model rendered in code! To accomplish this go to App.tsx, and import both Suspense from React and your model component.</p><pre>import { Suspense } from “react”;<br>import Model from &quot;./&lt;your-component-here&gt;&quot;;</pre><p>We are using Suspense here because per the gltfjsx docs:</p><blockquote>“It is asynchronous and therefore must be wrapped into &lt;Suspense&gt; which gives you full control over intermediary loading-fallbacks and error handling.”</blockquote><p>Now within your <em>&lt;</em>Canvas<em>&gt;</em> tags you can remove the mesh tags containing the default cube (if using the React Three Fiber template) and add:</p><pre> &lt;Suspense fallback={null}&gt;<br>   &lt;Model /&gt;<br> &lt;/Suspense&gt;</pre><p>Tada! 🎉 your model should be rendered! If it’s not try double-checking a few things:</p><ul><li>Your model should be included in your public folder</li><li>Check all file paths to the original .glb file in your models component</li><li>Ensure you exported your model correctly from Blender</li></ul><p><strong>Step 6:</strong> <em>Playing Animations</em>. Ok, the last step! All we have left to do now is to play the animations that we created in Blender. And lucky for us gltfjsx makes this incredibly easy. Open your models component and towards the top of the component we can see that gltfjsx has already prepared the clips from your file as actions in the following line:</p><pre>const { actions } = useAnimations&lt;GLTFActions&gt;(animations, group);</pre><p>*** If you do not see an actions variable declared in your component, this means that gltfjsx did not find any animations in your file. Therefore something went wrong when you baked the rigid body transformations to keyframes. It could be that the objects were not selected before you baked. If so, go back to Blender select everything that has a rigid body, bake, export and use the gltfjsx command again.</p><p>Under our actions variable, we can import and use the useEffect hook to loop over our actions and call play().</p><pre>useEffect(() =&gt; {</pre><pre> Object.keys(actions).forEach((key) =&gt; {</pre><pre>actions[key].play();</pre><pre>});</pre><pre>}, []);</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2Fio5l0&amp;display_name=CodeSandbox&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2Fio5l0&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2Fio5l0%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/6f35a38e692cd189c78561902a4aa404/href">https://medium.com/media/6f35a38e692cd189c78561902a4aa404/href</a></iframe><p>You can now take this project as far as you’d like! Change your materials, add events, play around with lighting, etc. If you create something fabulous tag me on Twitter @lnpepper so I can see!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dbd0299d4767" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Troubleshooting InstancedMesh in Three.js]]></title>
            <link>https://medium.com/@leannewerner/troubleshooting-instancedmesh-in-three-js-65e68b0a9753?source=rss-d27e6a24be1e------2</link>
            <guid isPermaLink="false">https://medium.com/p/65e68b0a9753</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[threejs]]></category>
            <category><![CDATA[3d]]></category>
            <dc:creator><![CDATA[Leanne Werner]]></dc:creator>
            <pubDate>Thu, 21 Oct 2021 20:39:20 GMT</pubDate>
            <atom:updated>2021-10-21T20:39:20.092Z</atom:updated>
            <content:encoded><![CDATA[<p>How to correctly use InstancedMesh.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cg3DRZF0NUHVTSc1tWGCJw.png" /><figcaption>Three.js InstancedMesh</figcaption></figure><p>According to the <a href="https://threejs.org/docs/index.html?q=instance#api/en/objects/InstancedMesh">Three.js docs</a>, you should use an instancedMesh when creating a lot of objects with the same geometry and material but have different world transformations. However, if you were to do a straight swap of your mesh say from</p><pre>THREE.Mesh(geometry, material)</pre><p>to</p><pre>THREE.InstancedMesh(geometry, material, count)</pre><p>you will notice that none of your mesh instances will appear on the screen.</p><p>This is because you must configure <em>each</em> instance transformation at least once. In other words, if you pass 10 in as your count parameter for InstancedMesh, but you only configure the instance transformation for the first item then you will only see one mesh instance render to the screen. You can read more about this in this <a href="https://discourse.threejs.org/t/instancedmesh-from-gltf-doesnt-work/16498/7">discourse thread</a>.</p><p>So how do you configure the instance transformation? Well in many of the Three.js examples regarding instancedMesh you will notice the use of a dummy object typically declared as:</p><pre>var dummy = new THREE.Object3D()</pre><p>This dummy object is used to access a local transform matrix so that we can use some conveniences such as properties and methods like dummy.position.set() to change the matrix. Without this we would need to declare and set a new THREE.Matrix4() which is not as user friendly.</p><p>Here is an example to both of those approaches, which will render the same result:</p><pre>const dummy = new THREE.Object3D()<br>const geometry = new THREE.BoxBufferGeometry(0.5, 0.5, 0.5)<br>const material = new THREE.MeshBasicMaterial()<br>const count = 3</pre><pre>const mesh = new THREE.InstancedMesh(geometry, material, count)<br>scene.add(mesh)</pre><pre>const offset = (count - 1) / 2</pre><pre>for (let i = 0; i &lt; count; i++) {<br>  dummy.position.set(offset - i, 0, 0)<br>  dummy.updateMatrix()<br>  mesh.setMatrixAt(i, dummy.matrix)<br>}</pre><p>is equivalent to…</p><pre>const matrix = new THREE.Matrix4()<br>const geometry = new THREE.BoxBufferGeometry(0.5, 0.5, 0.5)<br>const material = new THREE.MeshBasicMaterial()<br>const count = 3</pre><pre>const mesh = new THREE.InstancedMesh(geometry, material, count)<br>scene.add(mesh)</pre><pre>const offset = (count - 1) / 2</pre><pre>for (let i = 0; i &lt; count; i++) {<br> matrix.set(1, 0, 0, offset - i, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)<br> mesh.setMatrixAt(i, matrix)<br>}</pre><p>If you want to know more about how to use and configure transformation matrices, you can visit the docs <a href="https://threejs.org/docs/index.html?q=matrix#api/en/math/Matrix4">here</a>.</p><p>It is also worth noting that if you are using a ShaderMaterial for your instances you can use <a href="https://threejs.org/docs/index.html?q=instan#api/en/core/InstancedBufferAttribute">InstancedBufferAttribute</a> to pass instance specific data to your shader, you just need to specify one additional parameter, meshPerAttribute.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65e68b0a9753" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a Mouse Trail in Three.js]]></title>
            <link>https://medium.com/@leannewerner/creating-a-mouse-trail-in-three-js-fb15346ce784?source=rss-d27e6a24be1e------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb15346ce784</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[threejs]]></category>
            <dc:creator><![CDATA[Leanne Werner]]></dc:creator>
            <pubDate>Tue, 31 Aug 2021 21:46:37 GMT</pubDate>
            <atom:updated>2021-08-31T21:46:37.687Z</atom:updated>
            <content:encoded><![CDATA[<p>Who doesn’t love a good mouse trail? It’s a great way to waste more time than any of us would like to admit, and with three.js you can make something downright addictive. In this article, we are going to create a very basic mouse trail using particles that you can customize to your heart&#39;s desire.</p><figure><img alt="Photo by Richard Horvath on Unsplash" src="https://cdn-images-1.medium.com/max/1024/1*yS6tsUoNKHka-Fr5elDFQg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@orwhat?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Richard Horvath</a> on <a href="https://unsplash.com/s/photos/particles?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Step 1: Get your canvas and scene in place. Like the start of any new 3D project, let’s get all the basic parts together (scene, camera, renderer, etc.) and make sure everything renders correctly. For simplicity&#39;s sake, I’m just going to render a plane geometry to start with.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2Fos58k&amp;display_name=CodeSandbox&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2Fos58k&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2Fos58k%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/a56ddba3c9d2e85994f8222e46239496/href">https://medium.com/media/a56ddba3c9d2e85994f8222e46239496/href</a></iframe><p>Step 2: Now we are going to focus on changing our geometry from a plane to particles.</p><p>First, we need to change our PlaneGeometry to BufferGeometry.</p><p>Secondly, we need to change our Mesh class to Points.</p><p>Now at this point, you will see a Type Error: Cannot read property ‘array’ of undefined. This is because BufferGeometry expects that we at least set a position attribute. After all, what is geometry without any vertices? So we will create a setPositions() function that will take a typed array. This function is going to set three positions (x, y, and z) for every iteration of our for loop and return a typed array that contains the vertex data of all of our points. Now we can create the position attribute on our geometry (in this codesandbox I’m using addAttribute however in newer versions of three.js you will need to call setAttribute).</p><p>You should now see a lovely display of yellow dots!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2Fjb3hh&amp;display_name=CodeSandbox&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2Fjb3hh&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2Fjb3hh%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/d9f8703177611d2ff37890d4fbf44e4a/href">https://medium.com/media/d9f8703177611d2ff37890d4fbf44e4a/href</a></iframe><p>Step 3: We still need to get our mouse positions so we know where to reset our points when the cursor moves. For this, we will create a mouse variable that will store a Vector3 (the x,y, and z coordinates) of the mouse and a handleMouseMove function that will update those coordinates when the mouse moves. You will need to convert the screen coordinates to threejs world positions (lines 36 -40) for a more detailed explanation, see this <a href="https://stackoverflow.com/questions/13055214/mouse-canvas-x-y-to-three-js-world-x-y-z">StackOverflow post</a>. In this codesandbox you can see the logging of the mouse coordinates in the console.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2F56rgi&amp;display_name=CodeSandbox&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2F56rgi&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2F56rgi%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/afb3c4bab221fb0622b15aff6735796a/href">https://medium.com/media/afb3c4bab221fb0622b15aff6735796a/href</a></iframe><p>Step 4: Okay! Now that we have everything we need to make this mouse trail it&#39;s time to put all the pieces together. In our tick function, we are going to loop through all the particles and update their positions based on our new mouse coordinates. For the first particle, we will want to set the position to the mouse&#39;s current position. For every particle after the first one, we will set its position to a value that is the result of a <a href="https://threejs.org/docs/#api/en/math/Vector3.lerp">lerp</a> function between the current particle position and the previous particle position. This is what makes the particles look like they are ‘following’ each other. Stop here and play around with the alpha value on line 105. You’ll notice that the lower the number you assign, the slower your mouse trail will be. After the positions have been updated we need to tell three.js that the position attribute needs to be updated so we will set the needsUpdate flag on the position attribute to true.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2F1rp5o&amp;display_name=CodeSandbox&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2F1rp5o&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2F1rp5o%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ba0ee33494b74b8acd5971a809d96f3/href">https://medium.com/media/7ba0ee33494b74b8acd5971a809d96f3/href</a></iframe><p>Tada! you have a mouse trail 🎉. You can take this boilerplate code and change it to create whatever your imagination can think of. You can swap out the MeshBasicMaterial to a ShaderMaterial so you can have fine-tuned control over the vertices and colors. You can also add some physics to create more motion and animation. Also, If you want to create a mouse trail using lines I would check out this <a href="https://www.npmjs.com/package/meshline">meshline</a> library which combines the joys of lines with the convenience of mesh.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb15346ce784" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is a Float32Array?]]></title>
            <link>https://medium.com/@leannewerner/what-is-a-float32array-and-when-should-you-use-it-93cad8f3d34c?source=rss-d27e6a24be1e------2</link>
            <guid isPermaLink="false">https://medium.com/p/93cad8f3d34c</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[threejs]]></category>
            <category><![CDATA[shaders]]></category>
            <dc:creator><![CDATA[Leanne Werner]]></dc:creator>
            <pubDate>Mon, 09 Aug 2021 05:33:42 GMT</pubDate>
            <atom:updated>2021-08-09T05:35:13.575Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve been a frontend developer for a few years now working mostly in marketing, however recently I’ve delved into the fabulous world of graphics. The more code I read, the more I keep coming across this new-to-me term: Float32Array. So naturally, I wanted to know how this object is different than the regular Array object and why haven’t I come across this in the frontend/ marketing world yet see it everywhere when dealing with 2D and 3D graphics?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WRkNwOfAtJ-8V1B9LCDn8g.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@lanju_fotografie?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Lanju Fotografie</a> on <a href="https://unsplash.com/s/photos/graphics?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>After reading up on the documentation here&#39;s what I found:</p><p>A Float32Array is an array of 32-bit floating-point numbers while a normal Array is simply defined as a list-like object. So from these definitions, I can gather that a Float32Array is a typed array, meaning it expects to be populated with a specific type of data. But what exactly is a 32-bit floating-point number? Let’s break it down into two parts: 32-bit and floating-point.</p><p>Floating Point:<br>In short, a float is a data type used to store decimal numbers.</p><p>32 bit:<br>A 32-bit float uses 32 1’s and 0’s (bits) to store information about the decimal number. 1 bit is used to store the sign (negative or positive) of the number. 8 bits are used for the exponent of the number. The remaining 23 bits are used to store the mantissa, which is the part of the number that represents the significant digits.</p><p>So there we have it, the main difference between Array and Float32Array is that one is typed while the other is not. However, when is it appropriate to use a Float32Array over a normal Array? This <a href="https://stackoverflow.com/questions/15823021/when-to-use-float32array-instead-of-array-in-javascript">StackOverflow response</a> has some great answers. The author of the marked correct response answer noted that you can access data from typed arrays faster than normal arrays. This could have a big performance impact when dealing with very large data sets. In the 2D and 3D world, you may be dealing with many thousands of items within an array, particularly when working with particles or vertices. If you are doing multiple operations on these array items, then using a typed array has a performance advantage.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93cad8f3d34c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ShaderMaterial vs RawShaderMaterial]]></title>
            <link>https://medium.com/@leannewerner/shadermaterial-vs-rawshadermaterial-f1f0def5722?source=rss-d27e6a24be1e------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1f0def5722</guid>
            <category><![CDATA[shaders]]></category>
            <category><![CDATA[threejs]]></category>
            <category><![CDATA[glsl]]></category>
            <dc:creator><![CDATA[Leanne Werner]]></dc:creator>
            <pubDate>Wed, 21 Jul 2021 06:15:58 GMT</pubDate>
            <atom:updated>2021-07-21T06:15:58.317Z</atom:updated>
            <content:encoded><![CDATA[<p>List of the built in uniforms and attributes the WebGLProgram adds to your shader code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zdBfxjmMLTNlyH0iZoQnEA.jpeg" /></figure><p>You can create custom shaders in three.js using either the ShaderMaterial or the RawShaderMaterial class. Using the ShaderMaterial class will prepend some default uniforms and attributes to your GLSL code, while RawShaderMaterial will not. So what default code is added when using ShaderMaterial, and why is it useful?</p><p>The default code ShaderMaterial adds includes the following: <br><strong>Vertex Uniforms</strong><br>1) uniform mat4 modelMatrix;<br>2) uniform mat4 modelViewMatrix;<br>3) uniform mat4 projectionMatrix;<br>4) uniform mat4 viewMatrix;<br>5) uniform mat3 normalMatrix;<br>6) uniform vec3 cameraPosition;<br><strong>Vertex Attributes<br></strong>1) attribute vec3 position; <br>2) attribute vec3 normal; <br>3) attribute vec2 uv;</p><p><strong>Fragment Uniforms<br></strong>1) uniform mat4 viewMatrix; <br>2) uniform vec3 cameraPosition;</p><p>Not having to declare these common variables helps keep your GLSL code clean and concise.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1f0def5722" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why your sticky header won’t stick]]></title>
            <link>https://medium.com/@leannewerner/why-your-sticky-header-wont-stick-f0035535fc31?source=rss-d27e6a24be1e------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0035535fc31</guid>
            <category><![CDATA[html]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Leanne Werner]]></dc:creator>
            <pubDate>Fri, 29 Mar 2019 17:51:41 GMT</pubDate>
            <atom:updated>2019-03-29T17:51:41.205Z</atom:updated>
            <content:encoded><![CDATA[<p>A beginners guide to troubleshooting position: sticky</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9zo1AJQTHjL04i5ZGAlafw.jpeg" /><figcaption>Photo by Emily Morter on Unsplash</figcaption></figure><p>Using a sticky header on your web page is a great way to help give your users an easy way to navigate your site or display important alerts. However, this property can be tricky to use because it can often throw some unexpected behaviors. In this article, I will talk about the most common reasons a sticky header may not stick at all.</p><p>First, let’s talk a little bit about the sticky value in relation to other position values.</p><p>‘Sticky’ is a value of the CSS position property. Both the sticky and relative values give their elements a position within the normal flow of the document (unlike their siblings <em>fixed</em> and <em>absolute</em> which are positioned outside the normal flow of the document). This means that the element with position sticky, or relative, have a space in the page layout. Positions fixed and absolute, on the other hand, are ignored by the other elements on the page and thus do not have space in the <em>normal</em> flow of the document. It is important to know the differences in these values because position sticky works by <em>toggling between</em> relative and fixed positions.</p><p>Alright, now let’s take a look at some common pitfalls when working with the position: sticky property.</p><p><strong>3 Reasons sticky elements are not sticky.</strong></p><ol><li>Position sticky must be paired with one or multiple of the top, bottom, left, or right properties in order to do its job. This is because you must tell the element when to start to ‘stick’. For example, if you set position: sticky and top: 20px then you are telling the element to do two things. 1) The element will be position<em> relative</em> 20px from the top and 2) when the screen is scrolled so that the element would be less than 20px from the top, the element changes to position<em> fixed</em> ( and thus ‘stick’ )20px pixels from the top of its parent container.</li><li>A less obvious reason your sticky header may be giving you unexpected behavior is because of a parents overflow property. If the parent (or any ancestor for that matter) of a sticky element has overflow: hidden, scroll, or auto set then it becomes the scrolling container of your sticky element. This is because the sticky element will, “ stick to its nearest ancestor that has a scrolling mechanism” (“Position.” <em>MDN Web Docs</em>). Often times, this can make your sticky element appear to be broken because it applies to a different container than the one you may have intended. Because this rule applies to any ancestor of the position: sticky element, it can be hard to spot in your code and you may need to go pretty far up the DOM to catch it.</li></ol><p>In this pen, if you scroll within the blue grandparent container you will see that the header sticks at the top of this container (because overflow: scroll is set on grandparent) BUT! the header will still stop sticking at the bottom of its green parent container (the <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block">containing block</a>).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2FLeannePepper%2Fembed%2Fpreview%2FVNZaoM%3Fheight%3D600%26slug-hash%3DVNZaoM%26default-tabs%3Dhtml%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io&amp;url=https%3A%2F%2Fcodepen.io%2FLeannePepper%2Fpen%2FVNZaoM%3Feditors%3D1100&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fm.cdpn.io%2Fscreenshot-coming-soon-small.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c461c3f7dcff6f4cfe942e64aacd893/href">https://medium.com/media/7c461c3f7dcff6f4cfe942e64aacd893/href</a></iframe><p>3. OK let’s say you set your top, bottom, left or right property and you checked to make sure none of the sticky element’s ancestors have an overflow property set; yet your sticky element is still not behaving the way you want it to. Well, it’s important to remember that a sticky element will only stick within its parent container. For example, say you want a navigation bar to stick to the top of the page while the user scrolls. Maybe your code looks something like this…</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2FLeannePepper%2Fembed%2Fpreview%2FWWeoWL%3Fheight%3D600%26slug-hash%3DWWeoWL%26default-tabs%3Dhtml%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io&amp;url=https%3A%2F%2Fcodepen.io%2FLeannePepper%2Fpen%2FWWeoWL&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fm.cdpn.io%2Fscreenshot-coming-soon-small.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/efe50b1943f9781a11b537a5a09377a6/href">https://medium.com/media/efe50b1943f9781a11b537a5a09377a6/href</a></iframe><p>In this example, the header will stick to the top of the page just fine. However, if you change your code to this…</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2FLeannePepper%2Fembed%2Fpreview%2Faxopom%3Fheight%3D600%26slug-hash%3Daxopom%26default-tabs%3Dhtml%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io&amp;url=https%3A%2F%2Fcodepen.io%2FLeannePepper%2Fpen%2Faxopom&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fm.cdpn.io%2Fscreenshot-coming-soon-small.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/6882e5e02a2dba635d9c21dc3bb5a051/href">https://medium.com/media/6882e5e02a2dba635d9c21dc3bb5a051/href</a></iframe><p>This header will not stick to the top while the user scrolls down the web page. This is because the container in which the header will stick is no longer applied to the body of the document (like it is in the first example) it is only applied to the div with the class ‘parent’.</p><p>In conclusion, if your sticky header is not working as you would expect it to work make sure you check:</p><ul><li>You have a top, bottom, left or right property set</li><li>For the overflow property on any ancestor element</li><li>Your sticky element is being applied to your desired container</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0035535fc31" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>